/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-lenovo-dock-struct.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-mem-private.h"
#include "fu-string.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"

/**
 * fu_lenovo_dock_dsa_type_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_DSA_TYPE_RSA2048
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_dsa_type_to_string(FuLenovoDockDsaType val)
{
    if (val == FU_LENOVO_DOCK_DSA_TYPE_NONE)
        return "none";
    if (val == FU_LENOVO_DOCK_DSA_TYPE_RSA2048)
        return "rsa2048";
    if (val == FU_LENOVO_DOCK_DSA_TYPE_RSA3072)
        return "rsa3072";
    if (val == FU_LENOVO_DOCK_DSA_TYPE_ECC256)
        return "ecc256";
    if (val == FU_LENOVO_DOCK_DSA_TYPE_ECC384)
        return "ecc384";
    return NULL;
}

/**
 * fu_lenovo_dock_component_id_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_COMPONENT_ID_DMC
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_lenovo_dock_component_id_to_string(FuLenovoDockComponentId val)
{
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_NONE)
        return "none";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_DMC)
        return "dmc";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_DP)
        return "dp";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_PD)
        return "pd";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_USB3)
        return "usb3";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_USB4)
        return "usb4";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_OSD)
        return "osd";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_DBG)
        return "dbg";
    if (val == FU_LENOVO_DOCK_COMPONENT_ID_USAGE)
        return "usage";
    return NULL;
}

/**
 * fu_lenovo_dock_iot_flag_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_IOT_FLAG_MANAGED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_iot_flag_to_string(FuLenovoDockIotFlag val)
{
    if (val == FU_LENOVO_DOCK_IOT_FLAG_NATIVE)
        return "native";
    if (val == FU_LENOVO_DOCK_IOT_FLAG_MANAGED)
        return "managed";
    return NULL;
}

/**
 * fu_lenovo_dock_usage_item_flag_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_USAGE_ITEM_FLAG_DO_UPDATE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_usage_item_flag_to_string(FuLenovoDockUsageItemFlag val)
{
    if (val == FU_LENOVO_DOCK_USAGE_ITEM_FLAG_NONE)
        return "none";
    if (val == FU_LENOVO_DOCK_USAGE_ITEM_FLAG_DO_UPDATE)
        return "do-update";
    return NULL;
}

/**
 * fu_lenovo_dock_status_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_STATUS_BUSY
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_lenovo_dock_status_to_string(FuLenovoDockStatus val)
{
    if (val == FU_LENOVO_DOCK_STATUS_DEFAULT)
        return "default";
    if (val == FU_LENOVO_DOCK_STATUS_BUSY)
        return "busy";
    if (val == FU_LENOVO_DOCK_STATUS_SUCCESS)
        return "success";
    if (val == FU_LENOVO_DOCK_STATUS_FAILURE)
        return "failure";
    if (val == FU_LENOVO_DOCK_STATUS_TIMEOUT)
        return "timeout";
    if (val == FU_LENOVO_DOCK_STATUS_NOT_SUPPORT)
        return "not-support";
    return NULL;
}

/**
 * fu_lenovo_dock_cmd_class_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_CMD_CLASS_DFU
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_cmd_class_to_string(FuLenovoDockCmdClass val)
{
    if (val == FU_LENOVO_DOCK_CMD_CLASS_DEVICE_INFORMATION)
        return "device-information";
    if (val == FU_LENOVO_DOCK_CMD_CLASS_DFU)
        return "dfu";
    if (val == FU_LENOVO_DOCK_CMD_CLASS_TEST)
        return "test";
    if (val == FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH)
        return "external-flash";
    if (val == FU_LENOVO_DOCK_CMD_CLASS_DOCK)
        return "dock";
    return NULL;
}

/**
 * fu_lenovo_dock_cmd_id_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_CMD_ID_SET_SERIAL_NUMBER
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_cmd_id_to_string(FuLenovoDockCmdId val)
{
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_HARDWARE_VERSION)
        return "set-hardware-version";
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_SERIAL_NUMBER)
        return "set-serial-number";
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_DEVICE_MODE)
        return "set-device-mode";
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_DEVICE_EDITION)
        return "set-device-edition";
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_DEVICE_NAME)
        return "set-device-name";
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_DEVICE_RESET)
        return "set-device-reset";
    if (val == FU_LENOVO_DOCK_CMD_ID_SET_DEVICE_UUID)
        return "set-device-uuid";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_COMMAND_SUPPORT_LIST)
        return "get-command-support-list";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_FIRMWARE_VERSION)
        return "get-firmware-version";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_HARDWARE_VERSION)
        return "get-hardware-version";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_SERIAL_NUMBER)
        return "get-serial-number";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_MODE)
        return "get-device-mode";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_EDITION)
        return "get-device-edition";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_NAME)
        return "get-device-name";
    if (val == FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_UUID)
        return "get-device-uuid";
    return NULL;
}

/**
 * fu_lenovo_dock_notification_event_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_NOTIFICATION_EVENT_PORT_STATE_CHANGE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_lenovo_dock_notification_event_to_string(FuLenovoDockNotificationEvent val)
{
    if (val == FU_LENOVO_DOCK_NOTIFICATION_EVENT_DEBUG_LOG_PRINT)
        return "debug-log-print";
    if (val == FU_LENOVO_DOCK_NOTIFICATION_EVENT_PORT_STATE_CHANGE)
        return "port-state-change";
    if (val == FU_LENOVO_DOCK_NOTIFICATION_EVENT_PROVISION_STATE_UPDATE)
        return "provision-state-update";
    return NULL;
}

/**
 * fu_lenovo_dock_cfg_type_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_CFG_TYPE_CONNECTION
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_cfg_type_to_string(FuLenovoDockCfgType val)
{
    if (val == FU_LENOVO_DOCK_CFG_TYPE_PROVISION_STATE)
        return "provision-state";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_CONNECTION)
        return "connection";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_WIFI_SSID)
        return "wifi-ssid";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_WIFI_PASSWORD)
        return "wifi-password";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_WIFI_ROOT_CA)
        return "wifi-root-ca";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_WIFI_CLIENT_CA)
        return "wifi-client-ca";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_WIFI_CLIENT_KEY)
        return "wifi-client-key";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_WIFI_CLIENT_KEY_PASSWORD)
        return "wifi-client-key-password";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_PROVISION_TOKEN)
        return "provision-token";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_PROVISION_FLOW_CTRL)
        return "provision-flow-ctrl";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_PROVISION_URL)
        return "provision-url";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_EAP_IDENTITY)
        return "eap-identity";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_PROVISION_PUBLIC_KEY)
        return "provision-public-key";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_GET_IOT_MODULE_FW_VERSION)
        return "get-iot-module-fw-version";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_GET_IOT_MODULE_SN)
        return "get-iot-module-sn";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_GET_WIFI_MAC_ADDR)
        return "get-wifi-mac-addr";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_SET_IOT_EVT_BYPASS)
        return "set-iot-evt-bypass";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_EAP_USER_PASSWORD)
        return "eap-user-password";
    if (val == FU_LENOVO_DOCK_CFG_TYPE_MQTT_CA)
        return "mqtt-ca";
    return NULL;
}

/**
 * fu_lenovo_dock_provision_status_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_PROVISION_STATUS_PROVISIONED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_provision_status_to_string(FuLenovoDockProvisionStatus val)
{
    if (val == FU_LENOVO_DOCK_PROVISION_STATUS_NONE)
        return "none";
    if (val == FU_LENOVO_DOCK_PROVISION_STATUS_PROVISIONED)
        return "provisioned";
    return NULL;
}

/**
 * fu_lenovo_dock_internet_status_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_INTERNET_STATUS_CONNECTED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_internet_status_to_string(FuLenovoDockInternetStatus val)
{
    if (val == FU_LENOVO_DOCK_INTERNET_STATUS_NO_CONNECTION)
        return "no-connection";
    if (val == FU_LENOVO_DOCK_INTERNET_STATUS_CONNECTED)
        return "connected";
    return NULL;
}

/**
 * fu_lenovo_dock_cloud_register_state_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_CLOUD_REGISTER_STATE_REGISTERED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_cloud_register_state_to_string(FuLenovoDockCloudRegisterState val)
{
    if (val == FU_LENOVO_DOCK_CLOUD_REGISTER_STATE_NONE)
        return "none";
    if (val == FU_LENOVO_DOCK_CLOUD_REGISTER_STATE_REGISTERED)
        return "registered";
    return NULL;
}

/**
 * fu_lenovo_dock_flash_cmd_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_flash_cmd_to_string(FuLenovoDockFlashCmd val)
{
    if (val == FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_ID_USAGE_INFORMATION)
        return "set-flash-id-usage-information";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS)
        return "set-flash-memory-access";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_GET_SUPPORT_LIST)
        return "get-support-list";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ID_LIST)
        return "get-flash-id-list";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ATTRIBUTE)
        return "get-flash-attribute";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ID_USAGE_INFORMATION)
        return "get-flash-id-usage-information";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_ACCESS)
        return "get-flash-memory-access";
    if (val == FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY)
        return "get-flash-memory-self-verify";
    return NULL;
}

/**
 * fu_lenovo_dock_external_dock_cmd_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_FAN_CTRL
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_external_dock_cmd_to_string(FuLenovoDockExternalDockCmd val)
{
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_PORT_CTRL)
        return "set-dock-port-ctrl";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_FAN_CTRL)
        return "set-dock-fan-ctrl";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_IO_T_CONFIGURE)
        return "set-dock-io-t-configure";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_USB_CONTAINER_ID)
        return "set-dock-usb-container-id";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_LAN_MAC_ADDRESS)
        return "set-dock-lan-mac-address";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_AUX_LOG)
        return "set-dock-aux-log";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_FIRMWARE_UPGRADE_CTRL)
        return "set-dock-firmware-upgrade-ctrl";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_CMD_SUPPORT_LIST)
        return "get-cmd-support-list";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_ATTRIBUTE)
        return "get-dock-attribute";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_PORT_STATUS)
        return "get-dock-port-status";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_PORT_CTRL)
        return "get-dock-port-ctrl";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_PORT_CONNECTED_DEVICE_INFORMATION)
        return "get-dock-port-connected-device-information";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_FAN_CTRL)
        return "get-dock-fan-ctrl";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_IO_T_CONFIGURE)
        return "get-dock-io-t-configure";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_USB_CONTAINER_ID)
        return "get-dock-usb-container-id";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_LAN_MAC_ADDRESS)
        return "get-dock-lan-mac-address";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_AUX_LOG)
        return "get-dock-aux-log";
    if (val == FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_GET_DOCK_FIRMWARE_UPGRADE_CTRL)
        return "get-dock-firmware-upgrade-ctrl";
    return NULL;
}

/**
 * fu_lenovo_dock_component_purpose_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_COMPONENT_PURPOSE_APPLICATION_DATA
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_component_purpose_to_string(FuLenovoDockComponentPurpose val)
{
    if (val == FU_LENOVO_DOCK_COMPONENT_PURPOSE_COMMON)
        return "common";
    if (val == FU_LENOVO_DOCK_COMPONENT_PURPOSE_APPLICATION_DATA)
        return "application-data";
    if (val == FU_LENOVO_DOCK_COMPONENT_PURPOSE_IMAGE_DATA)
        return "image-data";
    if (val == FU_LENOVO_DOCK_COMPONENT_PURPOSE_FIRMWARE)
        return "firmware";
    return NULL;
}

/**
 * fu_lenovo_dock_flash_memory_access_cmd_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_ERASE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_flash_memory_access_cmd_to_string(FuLenovoDockFlashMemoryAccessCmd val)
{
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_ACCESS_CTRL)
        return "access-ctrl";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_ERASE)
        return "erase";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_PROGRAM)
        return "program";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_READ)
        return "read";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_ERASE)
        return "dock-erase";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_PROGRAM)
        return "dock-program";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_READ)
        return "dock-read";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_ERASE_WITH_ADDRESS)
        return "dock-erase-with-address";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_PROGRAM_WITH_ADDRESS)
        return "dock-program-with-address";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_READ_WITH_ADDRESS)
        return "dock-read-with-address";
    return NULL;
}

/**
 * fu_lenovo_dock_flash_memory_access_ctrl_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CTRL_REQUEST
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_flash_memory_access_ctrl_to_string(FuLenovoDockFlashMemoryAccessCtrl val)
{
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CTRL_RELEASE)
        return "release";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CTRL_REQUEST)
        return "request";
    return NULL;
}

/**
 * fu_lenovo_dock_flash_memory_self_verify_type_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_CRC
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_flash_memory_self_verify_type_to_string(FuLenovoDockFlashMemorySelfVerifyType val)
{
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_SIGNATURE)
        return "signature";
    if (val == FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_CRC)
        return "crc";
    return NULL;
}

/**
 * fu_lenovo_dock_flash_verify_signature_result_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FLASH_VERIFY_SIGNATURE_RESULT_PASS
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_flash_verify_signature_result_to_string(FuLenovoDockFlashVerifySignatureResult val)
{
    if (val == FU_LENOVO_DOCK_FLASH_VERIFY_SIGNATURE_RESULT_FAIL)
        return "fail";
    if (val == FU_LENOVO_DOCK_FLASH_VERIFY_SIGNATURE_RESULT_PASS)
        return "pass";
    return NULL;
}

/**
 * fu_lenovo_dock_fw_ctrl_upgrade_status_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FW_CTRL_UPGRADE_STATUS_LOCKED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_fw_ctrl_upgrade_status_to_string(FuLenovoDockFwCtrlUpgradeStatus val)
{
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_STATUS_NON_LOCK)
        return "non-lock";
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_STATUS_LOCKED)
        return "locked";
    return NULL;
}

/**
 * fu_lenovo_dock_fw_ctrl_upgrade_phase_ctrl_to_string:
 * @val: value, e.g. %FU_LENOVO_DOCK_FW_CTRL_UPGRADE_PHASE_CTRL_IN_PHASE1
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_lenovo_dock_fw_ctrl_upgrade_phase_ctrl_to_string(FuLenovoDockFwCtrlUpgradePhaseCtrl val)
{
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_PHASE_CTRL_NA)
        return "na";
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_PHASE_CTRL_IN_PHASE1)
        return "in-phase1";
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_PHASE_CTRL_UNPLUG)
        return "unplug";
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_PHASE_CTRL_NON_UNPLUG)
        return "non-unplug";
    if (val == FU_LENOVO_DOCK_FW_CTRL_UPGRADE_PHASE_CTRL_WAIT_FOR_TIMER)
        return "wait-for-timer";
    return NULL;
}
/**
 * fu_struct_lenovo_dock_usage_ref: (skip):
 **/
FuStructLenovoDockUsage *
fu_struct_lenovo_dock_usage_ref(FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_usage_unref: (skip):
 **/
void
fu_struct_lenovo_dock_usage_unref(FuStructLenovoDockUsage *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockUsage refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_usage_new_internal: (skip):
 **/
static FuStructLenovoDockUsage *
fu_struct_lenovo_dock_usage_new_internal(void)
{
    FuStructLenovoDockUsage *st = g_new0(FuStructLenovoDockUsage, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_usage_get_total_number: (skip):
 **/
guint8
fu_struct_lenovo_dock_usage_get_total_number(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_usage_get_major_version: (skip):
 **/
guint8
fu_struct_lenovo_dock_usage_get_major_version(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_usage_get_minor_version: (skip):
 **/
guint8
fu_struct_lenovo_dock_usage_get_minor_version(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_usage_get_dsa: (skip):
 **/
FuLenovoDockDsaType
fu_struct_lenovo_dock_usage_get_dsa(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_usage_get_iot_flag: (skip):
 **/
FuLenovoDockIotFlag
fu_struct_lenovo_dock_usage_get_iot_flag(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_usage_get_composite_version: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_get_composite_version(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->buf->data + 5, G_BIG_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_get_pid: (skip):
 **/
guint16
fu_struct_lenovo_dock_usage_get_pid(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_BIG_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_get_crc32: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_get_crc32(const FuStructLenovoDockUsage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_usage_set_total_number: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_total_number(FuStructLenovoDockUsage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_usage_set_major_version: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_major_version(FuStructLenovoDockUsage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_usage_set_minor_version: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_minor_version(FuStructLenovoDockUsage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_usage_set_dsa: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_dsa(FuStructLenovoDockUsage *st, FuLenovoDockDsaType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_usage_set_iot_flag: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_iot_flag(FuStructLenovoDockUsage *st, FuLenovoDockIotFlag value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_usage_set_composite_version: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_composite_version(FuStructLenovoDockUsage *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint24(st->buf->data + 5, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_set_pid: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_pid(FuStructLenovoDockUsage *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 8, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_set_crc32: (skip):
 **/
void
fu_struct_lenovo_dock_usage_set_crc32(FuStructLenovoDockUsage *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 10, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_usage_to_string(const FuStructLenovoDockUsage *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockUsage:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  total_number: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_get_total_number(st));
    g_string_append_printf(str, "  major_version: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_get_major_version(st));
    g_string_append_printf(str, "  minor_version: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_get_minor_version(st));
    {
        const gchar *tmp = fu_lenovo_dock_dsa_type_to_string(fu_struct_lenovo_dock_usage_get_dsa(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  dsa: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_usage_get_dsa(st), tmp);
        } else {
            g_string_append_printf(str, "  dsa: 0x%x\n", (guint) fu_struct_lenovo_dock_usage_get_dsa(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_iot_flag_to_string(fu_struct_lenovo_dock_usage_get_iot_flag(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  iot_flag: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_usage_get_iot_flag(st), tmp);
        } else {
            g_string_append_printf(str, "  iot_flag: 0x%x\n", (guint) fu_struct_lenovo_dock_usage_get_iot_flag(st));
        }
    }
    g_string_append_printf(str, "  composite_version: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_get_composite_version(st));
    g_string_append_printf(str, "  pid: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_get_pid(st));
    g_string_append_printf(str, "  crc32: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_get_crc32(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_usage_validate_internal(FuStructLenovoDockUsage *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_usage_parse_internal(FuStructLenovoDockUsage *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_usage_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_usage_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_usage_parse: (skip):
 **/
FuStructLenovoDockUsage *
fu_struct_lenovo_dock_usage_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockUsage) st = fu_struct_lenovo_dock_usage_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 32, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockUsage: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 32);
    if (!fu_struct_lenovo_dock_usage_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_usage_parse_stream: (skip):
 **/
FuStructLenovoDockUsage *
fu_struct_lenovo_dock_usage_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockUsage) st = fu_struct_lenovo_dock_usage_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructLenovoDockUsage failed read of 0x%x: ", (guint) 32);
        return NULL;
    }
    if (st->buf->len != 32) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructLenovoDockUsage requested 0x%x and got 0x%x",
                    (guint) 32,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_lenovo_dock_usage_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_usage_item_ref: (skip):
 **/
FuStructLenovoDockUsageItem *
fu_struct_lenovo_dock_usage_item_ref(FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_usage_item_unref: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_unref(FuStructLenovoDockUsageItem *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockUsageItem refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_usage_item_new_internal: (skip):
 **/
static FuStructLenovoDockUsageItem *
fu_struct_lenovo_dock_usage_item_new_internal(void)
{
    FuStructLenovoDockUsageItem *st = g_new0(FuStructLenovoDockUsageItem, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_usage_item_get_address: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_item_get_address(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_get_max_size: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_item_get_max_size(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_get_current_version: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_item_get_current_version(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_get_target_version: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_item_get_target_version(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_get_target_size: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_item_get_target_size(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_get_target_crc32: (skip):
 **/
guint32
fu_struct_lenovo_dock_usage_item_get_target_crc32(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_usage_item_get_component_id(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[24];
}
/**
 * fu_struct_lenovo_dock_usage_item_get_flag: (skip):
 **/
FuLenovoDockUsageItemFlag
fu_struct_lenovo_dock_usage_item_get_flag(const FuStructLenovoDockUsageItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[25];
}

/* setters */
/**
 * fu_struct_lenovo_dock_usage_item_set_address: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_address(FuStructLenovoDockUsageItem *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_set_max_size: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_max_size(FuStructLenovoDockUsageItem *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_set_current_version: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_current_version(FuStructLenovoDockUsageItem *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_set_target_version: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_target_version(FuStructLenovoDockUsageItem *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_set_target_size: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_target_size(FuStructLenovoDockUsageItem *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_set_target_crc32: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_target_crc32(FuStructLenovoDockUsageItem *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_usage_item_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_component_id(FuStructLenovoDockUsageItem *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[24] = value;
}
/**
 * fu_struct_lenovo_dock_usage_item_set_flag: (skip):
 **/
void
fu_struct_lenovo_dock_usage_item_set_flag(FuStructLenovoDockUsageItem *st, FuLenovoDockUsageItemFlag value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[25] = value;
}
/**
 * fu_struct_lenovo_dock_usage_item_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_usage_item_to_string(const FuStructLenovoDockUsageItem *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockUsageItem:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  address: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_item_get_address(st));
    g_string_append_printf(str, "  max_size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_item_get_max_size(st));
    g_string_append_printf(str, "  current_version: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_item_get_current_version(st));
    g_string_append_printf(str, "  target_version: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_item_get_target_version(st));
    g_string_append_printf(str, "  target_size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_item_get_target_size(st));
    g_string_append_printf(str, "  target_crc32: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_usage_item_get_target_crc32(st));
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_usage_item_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_usage_item_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_usage_item_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_usage_item_flag_to_string(fu_struct_lenovo_dock_usage_item_get_flag(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  flag: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_usage_item_get_flag(st), tmp);
        } else {
            g_string_append_printf(str, "  flag: 0x%x\n", (guint) fu_struct_lenovo_dock_usage_item_get_flag(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_usage_item_validate_internal(FuStructLenovoDockUsageItem *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_usage_item_parse_internal(FuStructLenovoDockUsageItem *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_usage_item_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_usage_item_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_usage_item_parse: (skip):
 **/
FuStructLenovoDockUsageItem *
fu_struct_lenovo_dock_usage_item_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockUsageItem) st = fu_struct_lenovo_dock_usage_item_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 32, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockUsageItem: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 32);
    if (!fu_struct_lenovo_dock_usage_item_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_usage_item_parse_stream: (skip):
 **/
FuStructLenovoDockUsageItem *
fu_struct_lenovo_dock_usage_item_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockUsageItem) st = fu_struct_lenovo_dock_usage_item_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructLenovoDockUsageItem failed read of 0x%x: ", (guint) 32);
        return NULL;
    }
    if (st->buf->len != 32) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructLenovoDockUsageItem requested 0x%x and got 0x%x",
                    (guint) 32,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_lenovo_dock_usage_item_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_generic_res_ref: (skip):
 **/
FuStructLenovoDockGenericRes *
fu_struct_lenovo_dock_generic_res_ref(FuStructLenovoDockGenericRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_generic_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_generic_res_unref(FuStructLenovoDockGenericRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGenericRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_generic_res_new_internal: (skip):
 **/
static FuStructLenovoDockGenericRes *
fu_struct_lenovo_dock_generic_res_new_internal(void)
{
    FuStructLenovoDockGenericRes *st = g_new0(FuStructLenovoDockGenericRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_generic_res_get_status: (skip):
 **/
FuLenovoDockStatus
fu_struct_lenovo_dock_generic_res_get_status(const FuStructLenovoDockGenericRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}

/* setters */
/**
 * fu_struct_lenovo_dock_generic_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_generic_res_to_string(const FuStructLenovoDockGenericRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockGenericRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_generic_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_generic_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_generic_res_get_status(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_generic_res_validate_internal(FuStructLenovoDockGenericRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_generic_res_parse_internal(FuStructLenovoDockGenericRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_generic_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_generic_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_generic_res_parse: (skip):
 **/
FuStructLenovoDockGenericRes *
fu_struct_lenovo_dock_generic_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockGenericRes) st = fu_struct_lenovo_dock_generic_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 1, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockGenericRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 1);
    if (!fu_struct_lenovo_dock_generic_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_notification_res_ref: (skip):
 **/
FuStructLenovoDockNotificationRes *
fu_struct_lenovo_dock_notification_res_ref(FuStructLenovoDockNotificationRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_notification_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_notification_res_unref(FuStructLenovoDockNotificationRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockNotificationRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_notification_res_new_internal: (skip):
 **/
static FuStructLenovoDockNotificationRes *
fu_struct_lenovo_dock_notification_res_new_internal(void)
{
    FuStructLenovoDockNotificationRes *st = g_new0(FuStructLenovoDockNotificationRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_notification_res_get_report_id: (skip):
 **/
static guint8
fu_struct_lenovo_dock_notification_res_get_report_id(const FuStructLenovoDockNotificationRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_notification_res_get_type: (skip):
 **/
static guint8
fu_struct_lenovo_dock_notification_res_get_type(const FuStructLenovoDockNotificationRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_notification_res_get_event: (skip):
 **/
FuLenovoDockNotificationEvent
fu_struct_lenovo_dock_notification_res_get_event(const FuStructLenovoDockNotificationRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}

/* setters */
/**
 * fu_struct_lenovo_dock_notification_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_notification_res_to_string(const FuStructLenovoDockNotificationRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockNotificationRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_notification_res_get_report_id(st));
    g_string_append_printf(str, "  type: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_notification_res_get_type(st));
    {
        const gchar *tmp = fu_lenovo_dock_notification_event_to_string(fu_struct_lenovo_dock_notification_res_get_event(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  event: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_notification_res_get_event(st), tmp);
        } else {
            g_string_append_printf(str, "  event: 0x%x\n", (guint) fu_struct_lenovo_dock_notification_res_get_event(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_notification_res_validate_internal(FuStructLenovoDockNotificationRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_notification_res_get_report_id(st) != 0x04) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockNotificationRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_notification_res_get_type(st) != 0x02) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockNotificationRes.type was not valid");
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_notification_res_parse_internal(FuStructLenovoDockNotificationRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_notification_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_notification_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_notification_res_parse: (skip):
 **/
FuStructLenovoDockNotificationRes *
fu_struct_lenovo_dock_notification_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockNotificationRes) st = fu_struct_lenovo_dock_notification_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 3, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockNotificationRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 3);
    if (!fu_struct_lenovo_dock_notification_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_get_version_req_ref: (skip):
 **/
FuStructLenovoDockGetVersionReq *
fu_struct_lenovo_dock_get_version_req_ref(FuStructLenovoDockGetVersionReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_get_version_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_get_version_req_unref(FuStructLenovoDockGetVersionReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGetVersionReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_get_version_req_new_internal: (skip):
 **/
static FuStructLenovoDockGetVersionReq *
fu_struct_lenovo_dock_get_version_req_new_internal(void)
{
    FuStructLenovoDockGetVersionReq *st = g_new0(FuStructLenovoDockGetVersionReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_lenovo_dock_get_version_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_get_version_req_set_status(FuStructLenovoDockGetVersionReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_get_version_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_get_version_req_set_datasz(FuStructLenovoDockGetVersionReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_get_version_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_get_version_req_set_cmd_class(FuStructLenovoDockGetVersionReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_get_version_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_get_version_req_set_cmd_id(FuStructLenovoDockGetVersionReq *st, FuLenovoDockCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_get_version_req_set_component_id: (skip):
 **/
static void
fu_struct_lenovo_dock_get_version_req_set_component_id(FuStructLenovoDockGetVersionReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_get_version_req_new: (skip):
 **/
FuStructLenovoDockGetVersionReq *
fu_struct_lenovo_dock_get_version_req_new(void)
{
    FuStructLenovoDockGetVersionReq *st = fu_struct_lenovo_dock_get_version_req_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_lenovo_dock_get_version_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_get_version_req_set_datasz(st, 0x02);
    fu_struct_lenovo_dock_get_version_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_DEVICE_INFORMATION);
    fu_struct_lenovo_dock_get_version_req_set_cmd_id(st, FU_LENOVO_DOCK_CMD_ID_GET_FIRMWARE_VERSION);
    fu_struct_lenovo_dock_get_version_req_set_component_id(st, FU_LENOVO_DOCK_COMPONENT_ID_NONE);
    return st;
}
/**
 * fu_struct_lenovo_dock_get_version_res_ref: (skip):
 **/
FuStructLenovoDockGetVersionRes *
fu_struct_lenovo_dock_get_version_res_ref(FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_get_version_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_get_version_res_unref(FuStructLenovoDockGetVersionRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGetVersionRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_get_version_res_new_internal: (skip):
 **/
static FuStructLenovoDockGetVersionRes *
fu_struct_lenovo_dock_get_version_res_new_internal(void)
{
    FuStructLenovoDockGetVersionRes *st = g_new0(FuStructLenovoDockGetVersionRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_get_version_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_get_version_res_get_status(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_get_version_res_get_datasz(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_get_version_res_get_cmd_class(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_cmd_id: (skip):
 **/
static FuLenovoDockCmdId
fu_struct_lenovo_dock_get_version_res_get_cmd_id(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_get_version_res_get_component_id(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_version_major: (skip):
 **/
guint8
fu_struct_lenovo_dock_get_version_res_get_version_major(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_version_minor: (skip):
 **/
guint8
fu_struct_lenovo_dock_get_version_res_get_version_minor(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[7];
}
/**
 * fu_struct_lenovo_dock_get_version_res_get_version_micro: (skip):
 **/
guint8
fu_struct_lenovo_dock_get_version_res_get_version_micro(const FuStructLenovoDockGetVersionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[8];
}

/* setters */
/**
 * fu_struct_lenovo_dock_get_version_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_get_version_res_to_string(const FuStructLenovoDockGetVersionRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockGetVersionRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_version_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_version_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_version_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_version_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_version_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_version_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_get_version_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_cmd_id_to_string(fu_struct_lenovo_dock_get_version_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_version_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_version_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_version_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_version_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_version_res_get_component_id(st));
        }
    }
    g_string_append_printf(str, "  version_major: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_version_res_get_version_major(st));
    g_string_append_printf(str, "  version_minor: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_version_res_get_version_minor(st));
    g_string_append_printf(str, "  version_micro: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_version_res_get_version_micro(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_get_version_res_validate_internal(FuStructLenovoDockGetVersionRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_get_version_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetVersionRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_version_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_version_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_version_res_get_datasz(st) != 0x03) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockGetVersionRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_version_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_DEVICE_INFORMATION) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetVersionRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_DEVICE_INFORMATION' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_version_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_version_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_version_res_get_cmd_id(st) != FU_LENOVO_DOCK_CMD_ID_GET_FIRMWARE_VERSION) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetVersionRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_ID_GET_FIRMWARE_VERSION' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_version_res_get_cmd_id(st),
                    fu_lenovo_dock_cmd_id_to_string(fu_struct_lenovo_dock_get_version_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_version_res_get_component_id(st) != FU_LENOVO_DOCK_COMPONENT_ID_NONE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetVersionRes.component_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_COMPONENT_ID_NONE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_version_res_get_component_id(st),
                    fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_version_res_get_component_id(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_get_version_res_parse_internal(FuStructLenovoDockGetVersionRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_get_version_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_get_version_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_get_version_res_parse: (skip):
 **/
FuStructLenovoDockGetVersionRes *
fu_struct_lenovo_dock_get_version_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockGetVersionRes) st = fu_struct_lenovo_dock_get_version_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 9, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockGetVersionRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 9);
    if (!fu_struct_lenovo_dock_get_version_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_get_edition_req_ref: (skip):
 **/
FuStructLenovoDockGetEditionReq *
fu_struct_lenovo_dock_get_edition_req_ref(FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_get_edition_req_unref(FuStructLenovoDockGetEditionReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGetEditionReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_get_edition_req_new_internal: (skip):
 **/
static FuStructLenovoDockGetEditionReq *
fu_struct_lenovo_dock_get_edition_req_new_internal(void)
{
    FuStructLenovoDockGetEditionReq *st = g_new0(FuStructLenovoDockGetEditionReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_get_edition_req_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_get_edition_req_get_status(const FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_get_edition_req_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_get_edition_req_get_datasz(const FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_get_edition_req_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_get_edition_req_get_cmd_class(const FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_get_edition_req_get_cmd_id: (skip):
 **/
static FuLenovoDockCmdId
fu_struct_lenovo_dock_get_edition_req_get_cmd_id(const FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_get_edition_req_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_get_edition_req_get_component_id(const FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_get_edition_req_get_cfg_type: (skip):
 **/
static FuLenovoDockCfgType
fu_struct_lenovo_dock_get_edition_req_get_cfg_type(const FuStructLenovoDockGetEditionReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}

/* setters */
/**
 * fu_struct_lenovo_dock_get_edition_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_get_edition_req_set_status(FuStructLenovoDockGetEditionReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_get_edition_req_set_datasz(FuStructLenovoDockGetEditionReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_get_edition_req_set_cmd_class(FuStructLenovoDockGetEditionReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_get_edition_req_set_cmd_id(FuStructLenovoDockGetEditionReq *st, FuLenovoDockCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_set_component_id: (skip):
 **/
static void
fu_struct_lenovo_dock_get_edition_req_set_component_id(FuStructLenovoDockGetEditionReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_set_cfg_type: (skip):
 **/
static void
fu_struct_lenovo_dock_get_edition_req_set_cfg_type(FuStructLenovoDockGetEditionReq *st, FuLenovoDockCfgType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_new: (skip):
 **/
FuStructLenovoDockGetEditionReq *
fu_struct_lenovo_dock_get_edition_req_new(void)
{
    FuStructLenovoDockGetEditionReq *st = fu_struct_lenovo_dock_get_edition_req_new_internal();
    st->buf = g_byte_array_sized_new(7);
    fu_byte_array_set_size(st->buf, 7, 0x0);
    fu_struct_lenovo_dock_get_edition_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_get_edition_req_set_datasz(st, 0x01);
    fu_struct_lenovo_dock_get_edition_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_DOCK);
    fu_struct_lenovo_dock_get_edition_req_set_cmd_id(st, FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_EDITION);
    fu_struct_lenovo_dock_get_edition_req_set_component_id(st, FU_LENOVO_DOCK_COMPONENT_ID_NONE);
    fu_struct_lenovo_dock_get_edition_req_set_cfg_type(st, FU_LENOVO_DOCK_CFG_TYPE_PROVISION_STATE);
    return st;
}
/**
 * fu_struct_lenovo_dock_get_edition_req_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_get_edition_req_to_string(const FuStructLenovoDockGetEditionReq *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockGetEditionReq:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_edition_req_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_edition_req_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_edition_req_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_cmd_id_to_string(fu_struct_lenovo_dock_get_edition_req_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_edition_req_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_cfg_type_to_string(fu_struct_lenovo_dock_get_edition_req_get_cfg_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cfg_type: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_cfg_type(st), tmp);
        } else {
            g_string_append_printf(str, "  cfg_type: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_req_get_cfg_type(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/**
 * fu_struct_lenovo_dock_get_edition_res_ref: (skip):
 **/
FuStructLenovoDockGetEditionRes *
fu_struct_lenovo_dock_get_edition_res_ref(FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_get_edition_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_get_edition_res_unref(FuStructLenovoDockGetEditionRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGetEditionRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_get_edition_res_new_internal: (skip):
 **/
static FuStructLenovoDockGetEditionRes *
fu_struct_lenovo_dock_get_edition_res_new_internal(void)
{
    FuStructLenovoDockGetEditionRes *st = g_new0(FuStructLenovoDockGetEditionRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_get_edition_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_get_edition_res_get_status(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_get_edition_res_get_datasz(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_get_edition_res_get_cmd_class(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_cmd_id: (skip):
 **/
static FuLenovoDockCmdId
fu_struct_lenovo_dock_get_edition_res_get_cmd_id(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_get_edition_res_get_component_id(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_cfg_type: (skip):
 **/
static FuLenovoDockCfgType
fu_struct_lenovo_dock_get_edition_res_get_cfg_type(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_provision_status: (skip):
 **/
FuLenovoDockProvisionStatus
fu_struct_lenovo_dock_get_edition_res_get_provision_status(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[7];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_internet_status: (skip):
 **/
FuLenovoDockInternetStatus
fu_struct_lenovo_dock_get_edition_res_get_internet_status(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[8];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_cloud_register_state: (skip):
 **/
FuLenovoDockCloudRegisterState
fu_struct_lenovo_dock_get_edition_res_get_cloud_register_state(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[9];
}
/**
 * fu_struct_lenovo_dock_get_edition_res_get_internet_connection_type: (skip):
 **/
guint8
fu_struct_lenovo_dock_get_edition_res_get_internet_connection_type(const FuStructLenovoDockGetEditionRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[10];
}

/* setters */
/**
 * fu_struct_lenovo_dock_get_edition_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_get_edition_res_to_string(const FuStructLenovoDockGetEditionRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockGetEditionRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_edition_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_edition_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_edition_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_cmd_id_to_string(fu_struct_lenovo_dock_get_edition_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_edition_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_cfg_type_to_string(fu_struct_lenovo_dock_get_edition_res_get_cfg_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cfg_type: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cfg_type(st), tmp);
        } else {
            g_string_append_printf(str, "  cfg_type: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cfg_type(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_provision_status_to_string(fu_struct_lenovo_dock_get_edition_res_get_provision_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  provision_status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_provision_status(st), tmp);
        } else {
            g_string_append_printf(str, "  provision_status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_provision_status(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_internet_status_to_string(fu_struct_lenovo_dock_get_edition_res_get_internet_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  internet_status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_internet_status(st), tmp);
        } else {
            g_string_append_printf(str, "  internet_status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_internet_status(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_cloud_register_state_to_string(fu_struct_lenovo_dock_get_edition_res_get_cloud_register_state(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cloud_register_state: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cloud_register_state(st), tmp);
        } else {
            g_string_append_printf(str, "  cloud_register_state: 0x%x\n", (guint) fu_struct_lenovo_dock_get_edition_res_get_cloud_register_state(st));
        }
    }
    g_string_append_printf(str, "  internet_connection_type: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_edition_res_get_internet_connection_type(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_get_edition_res_validate_internal(FuStructLenovoDockGetEditionRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_get_edition_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetEditionRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_edition_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_edition_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_edition_res_get_datasz(st) != 0x05) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockGetEditionRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_edition_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_DOCK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetEditionRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_DOCK' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_edition_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_edition_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_edition_res_get_cmd_id(st) != FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_EDITION) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetEditionRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_ID_GET_DEVICE_EDITION' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_edition_res_get_cmd_id(st),
                    fu_lenovo_dock_cmd_id_to_string(fu_struct_lenovo_dock_get_edition_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_edition_res_get_component_id(st) != FU_LENOVO_DOCK_COMPONENT_ID_NONE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetEditionRes.component_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_COMPONENT_ID_NONE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_edition_res_get_component_id(st),
                    fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_edition_res_get_component_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_edition_res_get_cfg_type(st) != FU_LENOVO_DOCK_CFG_TYPE_PROVISION_STATE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetEditionRes.cfg_type was not valid, "
                    "expected 'FU_LENOVO_DOCK_CFG_TYPE_PROVISION_STATE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_edition_res_get_cfg_type(st),
                    fu_lenovo_dock_cfg_type_to_string(fu_struct_lenovo_dock_get_edition_res_get_cfg_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_get_edition_res_parse_internal(FuStructLenovoDockGetEditionRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_get_edition_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_get_edition_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_get_edition_res_parse: (skip):
 **/
FuStructLenovoDockGetEditionRes *
fu_struct_lenovo_dock_get_edition_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockGetEditionRes) st = fu_struct_lenovo_dock_get_edition_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 11, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockGetEditionRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 11);
    if (!fu_struct_lenovo_dock_get_edition_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_ref: (skip):
 **/
FuStructLenovoDockFlashSetAccessReq *
fu_struct_lenovo_dock_flash_set_access_req_ref(FuStructLenovoDockFlashSetAccessReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_set_access_req_unref(FuStructLenovoDockFlashSetAccessReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashSetAccessReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashSetAccessReq *
fu_struct_lenovo_dock_flash_set_access_req_new_internal(void)
{
    FuStructLenovoDockFlashSetAccessReq *st = g_new0(FuStructLenovoDockFlashSetAccessReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_set_access_req_set_status(FuStructLenovoDockFlashSetAccessReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_set_access_req_set_datasz(FuStructLenovoDockFlashSetAccessReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_set_access_req_set_cmd_class(FuStructLenovoDockFlashSetAccessReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_set_access_req_set_cmd_id(FuStructLenovoDockFlashSetAccessReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_component_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_set_access_req_set_component_id(FuStructLenovoDockFlashSetAccessReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_cmd: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_set_access_req_set_cmd(FuStructLenovoDockFlashSetAccessReq *st, FuLenovoDockFlashMemoryAccessCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_set_ctrl: (skip):
 **/
void
fu_struct_lenovo_dock_flash_set_access_req_set_ctrl(FuStructLenovoDockFlashSetAccessReq *st, FuLenovoDockFlashMemoryAccessCtrl value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[7] = value;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_req_new: (skip):
 **/
FuStructLenovoDockFlashSetAccessReq *
fu_struct_lenovo_dock_flash_set_access_req_new(void)
{
    FuStructLenovoDockFlashSetAccessReq *st = fu_struct_lenovo_dock_flash_set_access_req_new_internal();
    st->buf = g_byte_array_sized_new(8);
    fu_byte_array_set_size(st->buf, 8, 0x0);
    fu_struct_lenovo_dock_flash_set_access_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_set_access_req_set_datasz(st, 0x02);
    fu_struct_lenovo_dock_flash_set_access_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_set_access_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS);
    fu_struct_lenovo_dock_flash_set_access_req_set_component_id(st, FU_LENOVO_DOCK_COMPONENT_ID_NONE);
    fu_struct_lenovo_dock_flash_set_access_req_set_cmd(st, FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_ACCESS_CTRL);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_ref: (skip):
 **/
FuStructLenovoDockFlashSetAccessRes *
fu_struct_lenovo_dock_flash_set_access_res_ref(FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_set_access_res_unref(FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashSetAccessRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashSetAccessRes *
fu_struct_lenovo_dock_flash_set_access_res_new_internal(void)
{
    FuStructLenovoDockFlashSetAccessRes *st = g_new0(FuStructLenovoDockFlashSetAccessRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_status: (skip):
 **/
FuLenovoDockStatus
fu_struct_lenovo_dock_flash_set_access_res_get_status(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_set_access_res_get_datasz(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_set_access_res_get_component_id(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_set_access_res_get_cmd(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_set_access_res_get_ctrl: (skip):
 **/
FuLenovoDockFlashMemoryAccessCtrl
fu_struct_lenovo_dock_flash_set_access_res_get_ctrl(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[7];
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_set_access_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_set_access_res_to_string(const FuStructLenovoDockFlashSetAccessRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashSetAccessRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_set_access_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_cmd(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_ctrl_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_ctrl(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  ctrl: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_ctrl(st), tmp);
        } else {
            g_string_append_printf(str, "  ctrl: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_set_access_res_get_ctrl(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_set_access_res_validate_internal(FuStructLenovoDockFlashSetAccessRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_set_access_res_get_datasz(st) != 0x02) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockFlashSetAccessRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashSetAccessRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashSetAccessRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_set_access_res_get_component_id(st) != FU_LENOVO_DOCK_COMPONENT_ID_NONE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashSetAccessRes.component_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_COMPONENT_ID_NONE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_set_access_res_get_component_id(st),
                    fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_component_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_set_access_res_get_cmd(st) != FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_ACCESS_CTRL) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashSetAccessRes.cmd was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_ACCESS_CTRL' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_set_access_res_get_cmd(st),
                    fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_set_access_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_set_access_res_parse_internal(FuStructLenovoDockFlashSetAccessRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_set_access_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_set_access_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_set_access_res_parse: (skip):
 **/
FuStructLenovoDockFlashSetAccessRes *
fu_struct_lenovo_dock_flash_set_access_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashSetAccessRes) st = fu_struct_lenovo_dock_flash_set_access_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 8, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashSetAccessRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 8);
    if (!fu_struct_lenovo_dock_flash_set_access_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_ref: (skip):
 **/
FuStructLenovoDockFlashGetAttrsReq *
fu_struct_lenovo_dock_flash_get_attrs_req_ref(FuStructLenovoDockFlashGetAttrsReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_get_attrs_req_unref(FuStructLenovoDockFlashGetAttrsReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashGetAttrsReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashGetAttrsReq *
fu_struct_lenovo_dock_flash_get_attrs_req_new_internal(void)
{
    FuStructLenovoDockFlashGetAttrsReq *st = g_new0(FuStructLenovoDockFlashGetAttrsReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_get_attrs_req_set_status(FuStructLenovoDockFlashGetAttrsReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_get_attrs_req_set_datasz(FuStructLenovoDockFlashGetAttrsReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_get_attrs_req_set_cmd_class(FuStructLenovoDockFlashGetAttrsReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_get_attrs_req_set_cmd_id(FuStructLenovoDockFlashGetAttrsReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_flash_get_attrs_req_set_component_id(FuStructLenovoDockFlashGetAttrsReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_req_new: (skip):
 **/
FuStructLenovoDockFlashGetAttrsReq *
fu_struct_lenovo_dock_flash_get_attrs_req_new(void)
{
    FuStructLenovoDockFlashGetAttrsReq *st = fu_struct_lenovo_dock_flash_get_attrs_req_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_lenovo_dock_flash_get_attrs_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_get_attrs_req_set_datasz(st, 0x00);
    fu_struct_lenovo_dock_flash_get_attrs_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_get_attrs_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ATTRIBUTE);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_ref: (skip):
 **/
FuStructLenovoDockFlashGetAttrsRes *
fu_struct_lenovo_dock_flash_get_attrs_res_ref(FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_get_attrs_res_unref(FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashGetAttrsRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashGetAttrsRes *
fu_struct_lenovo_dock_flash_get_attrs_res_new_internal(void)
{
    FuStructLenovoDockFlashGetAttrsRes *st = g_new0(FuStructLenovoDockFlashGetAttrsRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_get_attrs_res_get_status(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_get_attrs_res_get_datasz(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id_again: (skip):
 **/
guint8
fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id_again(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_purpose: (skip):
 **/
FuLenovoDockComponentPurpose
fu_struct_lenovo_dock_flash_get_attrs_res_get_purpose(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[7];
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_storage_size: (skip):
 **/
guint32
fu_struct_lenovo_dock_flash_get_attrs_res_get_storage_size(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_erase_size: (skip):
 **/
guint16
fu_struct_lenovo_dock_flash_get_attrs_res_get_erase_size(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_get_program_size: (skip):
 **/
guint16
fu_struct_lenovo_dock_flash_get_attrs_res_get_program_size(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 14, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_get_attrs_res_to_string(const FuStructLenovoDockFlashGetAttrsRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashGetAttrsRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id(st));
        }
    }
    g_string_append_printf(str, "  component_id_again: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_component_id_again(st));
    {
        const gchar *tmp = fu_lenovo_dock_component_purpose_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_purpose(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  purpose: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_purpose(st), tmp);
        } else {
            g_string_append_printf(str, "  purpose: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_purpose(st));
        }
    }
    g_string_append_printf(str, "  storage_size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_storage_size(st));
    g_string_append_printf(str, "  erase_size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_erase_size(st));
    g_string_append_printf(str, "  program_size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_get_attrs_res_get_program_size(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_get_attrs_res_validate_internal(FuStructLenovoDockFlashGetAttrsRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_get_attrs_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashGetAttrsRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_get_attrs_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_get_attrs_res_get_datasz(st) != 0x0A) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockFlashGetAttrsRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashGetAttrsRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ATTRIBUTE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashGetAttrsRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ATTRIBUTE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_get_attrs_res_get_cmd_id(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_get_attrs_res_parse_internal(FuStructLenovoDockFlashGetAttrsRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_get_attrs_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_get_attrs_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_get_attrs_res_parse: (skip):
 **/
FuStructLenovoDockFlashGetAttrsRes *
fu_struct_lenovo_dock_flash_get_attrs_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashGetAttrsRes) st = fu_struct_lenovo_dock_flash_get_attrs_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 16, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashGetAttrsRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 16);
    if (!fu_struct_lenovo_dock_flash_get_attrs_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_ref: (skip):
 **/
FuStructLenovoDockDfuControlReq *
fu_struct_lenovo_dock_dfu_control_req_ref(FuStructLenovoDockDfuControlReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_dfu_control_req_unref(FuStructLenovoDockDfuControlReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockDfuControlReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_new_internal: (skip):
 **/
static FuStructLenovoDockDfuControlReq *
fu_struct_lenovo_dock_dfu_control_req_new_internal(void)
{
    FuStructLenovoDockDfuControlReq *st = g_new0(FuStructLenovoDockDfuControlReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_dfu_control_req_set_status(FuStructLenovoDockDfuControlReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_dfu_control_req_set_datasz(FuStructLenovoDockDfuControlReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_dfu_control_req_set_cmd_class(FuStructLenovoDockDfuControlReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_dfu_control_req_set_cmd_id(FuStructLenovoDockDfuControlReq *st, FuLenovoDockExternalDockCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_component_id: (skip):
 **/
static void
fu_struct_lenovo_dock_dfu_control_req_set_component_id(FuStructLenovoDockDfuControlReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_upgrade_status: (skip):
 **/
void
fu_struct_lenovo_dock_dfu_control_req_set_upgrade_status(FuStructLenovoDockDfuControlReq *st, FuLenovoDockFwCtrlUpgradeStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_set_ctrl: (skip):
 **/
void
fu_struct_lenovo_dock_dfu_control_req_set_ctrl(FuStructLenovoDockDfuControlReq *st, FuLenovoDockFwCtrlUpgradePhaseCtrl value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[7] = value;
}
/**
 * fu_struct_lenovo_dock_dfu_control_req_new: (skip):
 **/
FuStructLenovoDockDfuControlReq *
fu_struct_lenovo_dock_dfu_control_req_new(void)
{
    FuStructLenovoDockDfuControlReq *st = fu_struct_lenovo_dock_dfu_control_req_new_internal();
    st->buf = g_byte_array_sized_new(8);
    fu_byte_array_set_size(st->buf, 8, 0x0);
    fu_struct_lenovo_dock_dfu_control_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_dfu_control_req_set_datasz(st, 0x02);
    fu_struct_lenovo_dock_dfu_control_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_DOCK);
    fu_struct_lenovo_dock_dfu_control_req_set_cmd_id(st, FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_FIRMWARE_UPGRADE_CTRL);
    fu_struct_lenovo_dock_dfu_control_req_set_component_id(st, FU_LENOVO_DOCK_COMPONENT_ID_NONE);
    return st;
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_ref: (skip):
 **/
FuStructLenovoDockDfuControlRes *
fu_struct_lenovo_dock_dfu_control_res_ref(FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_dfu_control_res_unref(FuStructLenovoDockDfuControlRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockDfuControlRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_new_internal: (skip):
 **/
static FuStructLenovoDockDfuControlRes *
fu_struct_lenovo_dock_dfu_control_res_new_internal(void)
{
    FuStructLenovoDockDfuControlRes *st = g_new0(FuStructLenovoDockDfuControlRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_dfu_control_res_get_status(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_dfu_control_res_get_datasz(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_cmd_id: (skip):
 **/
static FuLenovoDockExternalDockCmd
fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_dfu_control_res_get_component_id(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_upgrade_status: (skip):
 **/
FuLenovoDockFwCtrlUpgradeStatus
fu_struct_lenovo_dock_dfu_control_res_get_upgrade_status(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_dfu_control_res_get_ctrl: (skip):
 **/
FuLenovoDockFwCtrlUpgradePhaseCtrl
fu_struct_lenovo_dock_dfu_control_res_get_ctrl(const FuStructLenovoDockDfuControlRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[7];
}

/* setters */
/**
 * fu_struct_lenovo_dock_dfu_control_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_dfu_control_res_to_string(const FuStructLenovoDockDfuControlRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockDfuControlRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_dfu_control_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_dfu_control_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_external_dock_cmd_to_string(fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_dfu_control_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_fw_ctrl_upgrade_status_to_string(fu_struct_lenovo_dock_dfu_control_res_get_upgrade_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  upgrade_status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_upgrade_status(st), tmp);
        } else {
            g_string_append_printf(str, "  upgrade_status: 0x%x\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_upgrade_status(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_fw_ctrl_upgrade_phase_ctrl_to_string(fu_struct_lenovo_dock_dfu_control_res_get_ctrl(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  ctrl: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_ctrl(st), tmp);
        } else {
            g_string_append_printf(str, "  ctrl: 0x%x\n", (guint) fu_struct_lenovo_dock_dfu_control_res_get_ctrl(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_dfu_control_res_validate_internal(FuStructLenovoDockDfuControlRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_dfu_control_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockDfuControlRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_dfu_control_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_dfu_control_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_dfu_control_res_get_datasz(st) != 0x02) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockDfuControlRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_DOCK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockDfuControlRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_DOCK' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_dfu_control_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(st) != FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_FIRMWARE_UPGRADE_CTRL) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockDfuControlRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_EXTERNAL_DOCK_CMD_SET_DOCK_FIRMWARE_UPGRADE_CTRL' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(st),
                    fu_lenovo_dock_external_dock_cmd_to_string(fu_struct_lenovo_dock_dfu_control_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_dfu_control_res_get_component_id(st) != FU_LENOVO_DOCK_COMPONENT_ID_NONE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockDfuControlRes.component_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_COMPONENT_ID_NONE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_dfu_control_res_get_component_id(st),
                    fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_dfu_control_res_get_component_id(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_dfu_control_res_parse_internal(FuStructLenovoDockDfuControlRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_dfu_control_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_dfu_control_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_dfu_control_res_parse: (skip):
 **/
FuStructLenovoDockDfuControlRes *
fu_struct_lenovo_dock_dfu_control_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockDfuControlRes) st = fu_struct_lenovo_dock_dfu_control_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 8, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockDfuControlRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 8);
    if (!fu_struct_lenovo_dock_dfu_control_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_ref: (skip):
 **/
FuStructLenovoDockGetComponentIdListReq *
fu_struct_lenovo_dock_get_component_id_list_req_ref(FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_get_component_id_list_req_unref(FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGetComponentIdListReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_new_internal: (skip):
 **/
static FuStructLenovoDockGetComponentIdListReq *
fu_struct_lenovo_dock_get_component_id_list_req_new_internal(void)
{
    FuStructLenovoDockGetComponentIdListReq *st = g_new0(FuStructLenovoDockGetComponentIdListReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_get_component_id_list_req_get_status(const FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_get_component_id_list_req_get_datasz(const FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_class(const FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_id(const FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_get_component_id_list_req_get_component_id(const FuStructLenovoDockGetComponentIdListReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}

/* setters */
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_get_component_id_list_req_set_status(FuStructLenovoDockGetComponentIdListReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_get_component_id_list_req_set_datasz(FuStructLenovoDockGetComponentIdListReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_get_component_id_list_req_set_cmd_class(FuStructLenovoDockGetComponentIdListReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_get_component_id_list_req_set_cmd_id(FuStructLenovoDockGetComponentIdListReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_set_component_id: (skip):
 **/
static void
fu_struct_lenovo_dock_get_component_id_list_req_set_component_id(FuStructLenovoDockGetComponentIdListReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_new: (skip):
 **/
FuStructLenovoDockGetComponentIdListReq *
fu_struct_lenovo_dock_get_component_id_list_req_new(void)
{
    FuStructLenovoDockGetComponentIdListReq *st = fu_struct_lenovo_dock_get_component_id_list_req_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_lenovo_dock_get_component_id_list_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_get_component_id_list_req_set_datasz(st, 0x00);
    fu_struct_lenovo_dock_get_component_id_list_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_get_component_id_list_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ID_LIST);
    fu_struct_lenovo_dock_get_component_id_list_req_set_component_id(st, FU_LENOVO_DOCK_COMPONENT_ID_NONE);
    return st;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_req_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_get_component_id_list_req_to_string(const FuStructLenovoDockGetComponentIdListReq *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockGetComponentIdListReq:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_component_id_list_req_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_component_id_list_req_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_req_get_component_id(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_ref: (skip):
 **/
FuStructLenovoDockGetComponentIdListRes *
fu_struct_lenovo_dock_get_component_id_list_res_ref(FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_get_component_id_list_res_unref(FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockGetComponentIdListRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_new_internal: (skip):
 **/
static FuStructLenovoDockGetComponentIdListRes *
fu_struct_lenovo_dock_get_component_id_list_res_new_internal(void)
{
    FuStructLenovoDockGetComponentIdListRes *st = g_new0(FuStructLenovoDockGetComponentIdListRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_get_component_id_list_res_get_status(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_get_datasz: (skip):
 **/
guint8
fu_struct_lenovo_dock_get_component_id_list_res_get_datasz(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_get_total: (skip):
 **/
guint8
fu_struct_lenovo_dock_get_component_id_list_res_get_total(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}

/* setters */
/**
 * fu_struct_lenovo_dock_get_component_id_list_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_get_component_id_list_res_to_string(const FuStructLenovoDockGetComponentIdListRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockGetComponentIdListRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(st));
        }
    }
    g_string_append_printf(str, "  total: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_get_component_id_list_res_get_total(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_get_component_id_list_res_validate_internal(FuStructLenovoDockGetComponentIdListRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_get_component_id_list_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetComponentIdListRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_component_id_list_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetComponentIdListRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ID_LIST) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetComponentIdListRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_ID_LIST' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(st) != FU_LENOVO_DOCK_COMPONENT_ID_NONE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockGetComponentIdListRes.component_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_COMPONENT_ID_NONE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(st),
                    fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_get_component_id_list_res_get_component_id(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_get_component_id_list_res_parse_internal(FuStructLenovoDockGetComponentIdListRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_get_component_id_list_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_get_component_id_list_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_get_component_id_list_res_parse: (skip):
 **/
FuStructLenovoDockGetComponentIdListRes *
fu_struct_lenovo_dock_get_component_id_list_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockGetComponentIdListRes) st = fu_struct_lenovo_dock_get_component_id_list_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 7, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockGetComponentIdListRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 7);
    if (!fu_struct_lenovo_dock_get_component_id_list_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_read_req_ref: (skip):
 **/
FuStructLenovoDockFlashReadReq *
fu_struct_lenovo_dock_flash_read_req_ref(FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_read_req_unref(FuStructLenovoDockFlashReadReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashReadReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_read_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashReadReq *
fu_struct_lenovo_dock_flash_read_req_new_internal(void)
{
    FuStructLenovoDockFlashReadReq *st = g_new0(FuStructLenovoDockFlashReadReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_read_req_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_read_req_get_status(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_read_req_get_datasz(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_read_req_get_cmd_class(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_read_req_get_cmd_id(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_read_req_get_component_id(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_memory_access_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_read_req_get_memory_access_cmd(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_size: (skip):
 **/
static guint16
fu_struct_lenovo_dock_flash_read_req_get_size(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_read_req_get_addr: (skip):
 **/
static guint32
fu_struct_lenovo_dock_flash_read_req_get_addr(const FuStructLenovoDockFlashReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_read_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_read_req_set_status(FuStructLenovoDockFlashReadReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_read_req_set_datasz(FuStructLenovoDockFlashReadReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_read_req_set_cmd_class(FuStructLenovoDockFlashReadReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_read_req_set_cmd_id(FuStructLenovoDockFlashReadReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_flash_read_req_set_component_id(FuStructLenovoDockFlashReadReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_memory_access_cmd: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_read_req_set_memory_access_cmd(FuStructLenovoDockFlashReadReq *st, FuLenovoDockFlashMemoryAccessCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_size: (skip):
 **/
void
fu_struct_lenovo_dock_flash_read_req_set_size(FuStructLenovoDockFlashReadReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 8, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_read_req_set_addr: (skip):
 **/
void
fu_struct_lenovo_dock_flash_read_req_set_addr(FuStructLenovoDockFlashReadReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 10, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_read_req_new: (skip):
 **/
FuStructLenovoDockFlashReadReq *
fu_struct_lenovo_dock_flash_read_req_new(void)
{
    FuStructLenovoDockFlashReadReq *st = fu_struct_lenovo_dock_flash_read_req_new_internal();
    st->buf = g_byte_array_sized_new(14);
    fu_byte_array_set_size(st->buf, 14, 0x0);
    fu_struct_lenovo_dock_flash_read_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_read_req_set_datasz(st, 0x08);
    fu_struct_lenovo_dock_flash_read_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_read_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_ACCESS);
    fu_struct_lenovo_dock_flash_read_req_set_memory_access_cmd(st, FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_READ_WITH_ADDRESS);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_read_req_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_flash_read_req_to_string(const FuStructLenovoDockFlashReadReq *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashReadReq:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_read_req_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_read_req_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_read_req_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_read_req_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_read_req_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_read_req_get_memory_access_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_memory_access_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_req_get_memory_access_cmd(st));
        }
    }
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_read_req_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_read_req_get_addr(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/**
 * fu_struct_lenovo_dock_flash_read_res_ref: (skip):
 **/
FuStructLenovoDockFlashReadRes *
fu_struct_lenovo_dock_flash_read_res_ref(FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_read_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_read_res_unref(FuStructLenovoDockFlashReadRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashReadRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_read_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashReadRes *
fu_struct_lenovo_dock_flash_read_res_new_internal(void)
{
    FuStructLenovoDockFlashReadRes *st = g_new0(FuStructLenovoDockFlashReadRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_read_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_read_res_get_status(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_read_res_get_datasz(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_read_res_get_cmd_class(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_read_res_get_cmd_id(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_read_res_get_component_id(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_size: (skip):
 **/
guint16
fu_struct_lenovo_dock_flash_read_res_get_size(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_addr: (skip):
 **/
guint32
fu_struct_lenovo_dock_flash_read_res_get_addr(const FuStructLenovoDockFlashReadRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_read_res_get_data: (skip):
 **/
const guint8 *
fu_struct_lenovo_dock_flash_read_res_get_data(const FuStructLenovoDockFlashReadRes *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 256;
    return st->buf->data + 14;
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_read_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_read_res_to_string(const FuStructLenovoDockFlashReadRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashReadRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_read_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_read_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_read_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_read_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_read_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(st));
        }
    }
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_read_res_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_read_res_get_addr(st));
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_lenovo_dock_flash_read_res_get_data(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  data: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_read_res_validate_internal(FuStructLenovoDockFlashReadRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_read_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashReadRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_read_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_read_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_read_res_get_datasz(st) != 0x00) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockFlashReadRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_read_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashReadRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_read_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_read_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_read_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_ACCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashReadRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_ACCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_read_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_read_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(st) != FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_READ_WITH_ADDRESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashReadRes.memory_access_cmd was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_READ_WITH_ADDRESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(st),
                    fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_read_res_get_memory_access_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_read_res_parse_internal(FuStructLenovoDockFlashReadRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_read_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_read_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_read_res_parse: (skip):
 **/
FuStructLenovoDockFlashReadRes *
fu_struct_lenovo_dock_flash_read_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashReadRes) st = fu_struct_lenovo_dock_flash_read_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 270, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashReadRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 270);
    if (!fu_struct_lenovo_dock_flash_read_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_ref: (skip):
 **/
FuStructLenovoDockFlashEraseReq *
fu_struct_lenovo_dock_flash_erase_req_ref(FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_erase_req_unref(FuStructLenovoDockFlashEraseReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashEraseReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashEraseReq *
fu_struct_lenovo_dock_flash_erase_req_new_internal(void)
{
    FuStructLenovoDockFlashEraseReq *st = g_new0(FuStructLenovoDockFlashEraseReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_erase_req_get_status(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_erase_req_get_datasz(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_erase_req_get_cmd_class(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_erase_req_get_cmd_id(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_erase_req_get_component_id(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_memory_access_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_erase_req_get_memory_access_cmd(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_size: (skip):
 **/
static guint16
fu_struct_lenovo_dock_flash_erase_req_get_size(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_get_addr: (skip):
 **/
static guint32
fu_struct_lenovo_dock_flash_erase_req_get_addr(const FuStructLenovoDockFlashEraseReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_erase_req_set_status(FuStructLenovoDockFlashEraseReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_erase_req_set_datasz(FuStructLenovoDockFlashEraseReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_erase_req_set_cmd_class(FuStructLenovoDockFlashEraseReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_erase_req_set_cmd_id(FuStructLenovoDockFlashEraseReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_flash_erase_req_set_component_id(FuStructLenovoDockFlashEraseReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_memory_access_cmd: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_erase_req_set_memory_access_cmd(FuStructLenovoDockFlashEraseReq *st, FuLenovoDockFlashMemoryAccessCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_size: (skip):
 **/
void
fu_struct_lenovo_dock_flash_erase_req_set_size(FuStructLenovoDockFlashEraseReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 8, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_set_addr: (skip):
 **/
void
fu_struct_lenovo_dock_flash_erase_req_set_addr(FuStructLenovoDockFlashEraseReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 10, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_new: (skip):
 **/
FuStructLenovoDockFlashEraseReq *
fu_struct_lenovo_dock_flash_erase_req_new(void)
{
    FuStructLenovoDockFlashEraseReq *st = fu_struct_lenovo_dock_flash_erase_req_new_internal();
    st->buf = g_byte_array_sized_new(14);
    fu_byte_array_set_size(st->buf, 14, 0x0);
    fu_struct_lenovo_dock_flash_erase_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_erase_req_set_datasz(st, 0x08);
    fu_struct_lenovo_dock_flash_erase_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_erase_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS);
    fu_struct_lenovo_dock_flash_erase_req_set_memory_access_cmd(st, FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_ERASE_WITH_ADDRESS);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_erase_req_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_flash_erase_req_to_string(const FuStructLenovoDockFlashEraseReq *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashEraseReq:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_erase_req_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_erase_req_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_erase_req_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_erase_req_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_erase_req_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_erase_req_get_memory_access_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_memory_access_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_req_get_memory_access_cmd(st));
        }
    }
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_erase_req_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_erase_req_get_addr(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_ref: (skip):
 **/
FuStructLenovoDockFlashEraseRes *
fu_struct_lenovo_dock_flash_erase_res_ref(FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_erase_res_unref(FuStructLenovoDockFlashEraseRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashEraseRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashEraseRes *
fu_struct_lenovo_dock_flash_erase_res_new_internal(void)
{
    FuStructLenovoDockFlashEraseRes *st = g_new0(FuStructLenovoDockFlashEraseRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_erase_res_get_status(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_erase_res_get_datasz(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_erase_res_get_component_id(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_size: (skip):
 **/
guint16
fu_struct_lenovo_dock_flash_erase_res_get_size(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_erase_res_get_addr: (skip):
 **/
guint32
fu_struct_lenovo_dock_flash_erase_res_get_addr(const FuStructLenovoDockFlashEraseRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_erase_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_erase_res_to_string(const FuStructLenovoDockFlashEraseRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashEraseRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_erase_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_erase_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_erase_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(st));
        }
    }
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_erase_res_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_erase_res_get_addr(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_erase_res_validate_internal(FuStructLenovoDockFlashEraseRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_erase_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashEraseRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_erase_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_erase_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_erase_res_get_datasz(st) != 0x08) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockFlashEraseRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashEraseRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_erase_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashEraseRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_erase_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(st) != FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_ERASE_WITH_ADDRESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashEraseRes.memory_access_cmd was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_ERASE_WITH_ADDRESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(st),
                    fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_erase_res_get_memory_access_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_erase_res_parse_internal(FuStructLenovoDockFlashEraseRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_erase_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_erase_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_erase_res_parse: (skip):
 **/
FuStructLenovoDockFlashEraseRes *
fu_struct_lenovo_dock_flash_erase_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashEraseRes) st = fu_struct_lenovo_dock_flash_erase_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 14, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashEraseRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 14);
    if (!fu_struct_lenovo_dock_flash_erase_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_program_req_ref: (skip):
 **/
FuStructLenovoDockFlashProgramReq *
fu_struct_lenovo_dock_flash_program_req_ref(FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_program_req_unref(FuStructLenovoDockFlashProgramReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashProgramReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_program_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashProgramReq *
fu_struct_lenovo_dock_flash_program_req_new_internal(void)
{
    FuStructLenovoDockFlashProgramReq *st = g_new0(FuStructLenovoDockFlashProgramReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_program_req_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_program_req_get_status(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_program_req_get_datasz(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_program_req_get_cmd_class(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_program_req_get_cmd_id(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_component_id: (skip):
 **/
static FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_program_req_get_component_id(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_memory_access_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_program_req_get_memory_access_cmd(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_size: (skip):
 **/
static guint16
fu_struct_lenovo_dock_flash_program_req_get_size(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_program_req_get_addr: (skip):
 **/
static guint32
fu_struct_lenovo_dock_flash_program_req_get_addr(const FuStructLenovoDockFlashProgramReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_program_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_program_req_set_status(FuStructLenovoDockFlashProgramReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_datasz: (skip):
 **/
void
fu_struct_lenovo_dock_flash_program_req_set_datasz(FuStructLenovoDockFlashProgramReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_program_req_set_cmd_class(FuStructLenovoDockFlashProgramReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_program_req_set_cmd_id(FuStructLenovoDockFlashProgramReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_flash_program_req_set_component_id(FuStructLenovoDockFlashProgramReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_memory_access_cmd: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_program_req_set_memory_access_cmd(FuStructLenovoDockFlashProgramReq *st, FuLenovoDockFlashMemoryAccessCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_size: (skip):
 **/
void
fu_struct_lenovo_dock_flash_program_req_set_size(FuStructLenovoDockFlashProgramReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 8, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_program_req_set_addr: (skip):
 **/
void
fu_struct_lenovo_dock_flash_program_req_set_addr(FuStructLenovoDockFlashProgramReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 10, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_program_req_new: (skip):
 **/
FuStructLenovoDockFlashProgramReq *
fu_struct_lenovo_dock_flash_program_req_new(void)
{
    FuStructLenovoDockFlashProgramReq *st = fu_struct_lenovo_dock_flash_program_req_new_internal();
    st->buf = g_byte_array_sized_new(14);
    fu_byte_array_set_size(st->buf, 14, 0x0);
    fu_struct_lenovo_dock_flash_program_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_program_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_program_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS);
    fu_struct_lenovo_dock_flash_program_req_set_memory_access_cmd(st, FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_PROGRAM_WITH_ADDRESS);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_program_req_to_string: (skip):
 **/
gchar *
fu_struct_lenovo_dock_flash_program_req_to_string(const FuStructLenovoDockFlashProgramReq *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashProgramReq:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_program_req_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_program_req_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_program_req_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_program_req_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_program_req_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_program_req_get_memory_access_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_memory_access_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_req_get_memory_access_cmd(st));
        }
    }
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_program_req_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_program_req_get_addr(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/**
 * fu_struct_lenovo_dock_flash_program_res_ref: (skip):
 **/
FuStructLenovoDockFlashProgramRes *
fu_struct_lenovo_dock_flash_program_res_ref(FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_program_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_program_res_unref(FuStructLenovoDockFlashProgramRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashProgramRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_program_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashProgramRes *
fu_struct_lenovo_dock_flash_program_res_new_internal(void)
{
    FuStructLenovoDockFlashProgramRes *st = g_new0(FuStructLenovoDockFlashProgramRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_program_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_program_res_get_status(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_datasz: (skip):
 **/
guint8
fu_struct_lenovo_dock_flash_program_res_get_datasz(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_program_res_get_cmd_class(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_program_res_get_cmd_id(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_program_res_get_component_id(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd: (skip):
 **/
static FuLenovoDockFlashMemoryAccessCmd
fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_size: (skip):
 **/
guint16
fu_struct_lenovo_dock_flash_program_res_get_size(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_lenovo_dock_flash_program_res_get_addr: (skip):
 **/
guint32
fu_struct_lenovo_dock_flash_program_res_get_addr(const FuStructLenovoDockFlashProgramRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_program_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_program_res_to_string(const FuStructLenovoDockFlashProgramRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashProgramRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_program_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_program_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_program_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_program_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_program_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  memory_access_cmd: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(st));
        }
    }
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_program_res_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_program_res_get_addr(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_program_res_validate_internal(FuStructLenovoDockFlashProgramRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_program_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashProgramRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_program_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_program_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_program_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashProgramRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_program_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_program_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_program_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashProgramRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_SET_FLASH_MEMORY_ACCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_program_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_program_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(st) != FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_PROGRAM_WITH_ADDRESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashProgramRes.memory_access_cmd was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_MEMORY_ACCESS_CMD_DOCK_PROGRAM_WITH_ADDRESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(st),
                    fu_lenovo_dock_flash_memory_access_cmd_to_string(fu_struct_lenovo_dock_flash_program_res_get_memory_access_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_program_res_parse_internal(FuStructLenovoDockFlashProgramRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_program_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_program_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_program_res_parse: (skip):
 **/
FuStructLenovoDockFlashProgramRes *
fu_struct_lenovo_dock_flash_program_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashProgramRes) st = fu_struct_lenovo_dock_flash_program_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 14, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashProgramRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 14);
    if (!fu_struct_lenovo_dock_flash_program_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_ref: (skip):
 **/
FuStructLenovoDockFlashVerifyCrcReq *
fu_struct_lenovo_dock_flash_verify_crc_req_ref(FuStructLenovoDockFlashVerifyCrcReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_verify_crc_req_unref(FuStructLenovoDockFlashVerifyCrcReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashVerifyCrcReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashVerifyCrcReq *
fu_struct_lenovo_dock_flash_verify_crc_req_new_internal(void)
{
    FuStructLenovoDockFlashVerifyCrcReq *st = g_new0(FuStructLenovoDockFlashVerifyCrcReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_crc_req_set_status(FuStructLenovoDockFlashVerifyCrcReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_crc_req_set_datasz(FuStructLenovoDockFlashVerifyCrcReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_crc_req_set_cmd_class(FuStructLenovoDockFlashVerifyCrcReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_crc_req_set_cmd_id(FuStructLenovoDockFlashVerifyCrcReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_flash_verify_crc_req_set_component_id(FuStructLenovoDockFlashVerifyCrcReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_set_type: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_crc_req_set_type(FuStructLenovoDockFlashVerifyCrcReq *st, FuLenovoDockFlashMemorySelfVerifyType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_req_new: (skip):
 **/
FuStructLenovoDockFlashVerifyCrcReq *
fu_struct_lenovo_dock_flash_verify_crc_req_new(void)
{
    FuStructLenovoDockFlashVerifyCrcReq *st = fu_struct_lenovo_dock_flash_verify_crc_req_new_internal();
    st->buf = g_byte_array_sized_new(7);
    fu_byte_array_set_size(st->buf, 7, 0x0);
    fu_struct_lenovo_dock_flash_verify_crc_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_verify_crc_req_set_datasz(st, 0x01);
    fu_struct_lenovo_dock_flash_verify_crc_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_verify_crc_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY);
    fu_struct_lenovo_dock_flash_verify_crc_req_set_type(st, FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_CRC);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_ref: (skip):
 **/
FuStructLenovoDockFlashVerifyCrcRes *
fu_struct_lenovo_dock_flash_verify_crc_res_ref(FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_verify_crc_res_unref(FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashVerifyCrcRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashVerifyCrcRes *
fu_struct_lenovo_dock_flash_verify_crc_res_new_internal(void)
{
    FuStructLenovoDockFlashVerifyCrcRes *st = g_new0(FuStructLenovoDockFlashVerifyCrcRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_verify_crc_res_get_status(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_verify_crc_res_get_datasz(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_verify_crc_res_get_component_id(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_type: (skip):
 **/
static FuLenovoDockFlashMemorySelfVerifyType
fu_struct_lenovo_dock_flash_verify_crc_res_get_type(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_get_crc: (skip):
 **/
guint32
fu_struct_lenovo_dock_flash_verify_crc_res_get_crc(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 7, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_verify_crc_res_to_string(const FuStructLenovoDockFlashVerifyCrcRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashVerifyCrcRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_self_verify_type_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  type: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_type(st), tmp);
        } else {
            g_string_append_printf(str, "  type: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_type(st));
        }
    }
    g_string_append_printf(str, "  crc: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_verify_crc_res_get_crc(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_verify_crc_res_validate_internal(FuStructLenovoDockFlashVerifyCrcRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_verify_crc_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifyCrcRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_crc_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_crc_res_get_datasz(st) != 0x5) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockFlashVerifyCrcRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifyCrcRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifyCrcRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_crc_res_get_type(st) != FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_CRC) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifyCrcRes.type was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_CRC' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_crc_res_get_type(st),
                    fu_lenovo_dock_flash_memory_self_verify_type_to_string(fu_struct_lenovo_dock_flash_verify_crc_res_get_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_verify_crc_res_parse_internal(FuStructLenovoDockFlashVerifyCrcRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_verify_crc_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_verify_crc_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_verify_crc_res_parse: (skip):
 **/
FuStructLenovoDockFlashVerifyCrcRes *
fu_struct_lenovo_dock_flash_verify_crc_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashVerifyCrcRes) st = fu_struct_lenovo_dock_flash_verify_crc_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 11, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashVerifyCrcRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 11);
    if (!fu_struct_lenovo_dock_flash_verify_crc_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_ref: (skip):
 **/
FuStructLenovoDockFlashVerifySignatureReq *
fu_struct_lenovo_dock_flash_verify_signature_req_ref(FuStructLenovoDockFlashVerifySignatureReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_verify_signature_req_unref(FuStructLenovoDockFlashVerifySignatureReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashVerifySignatureReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_new_internal: (skip):
 **/
static FuStructLenovoDockFlashVerifySignatureReq *
fu_struct_lenovo_dock_flash_verify_signature_req_new_internal(void)
{
    FuStructLenovoDockFlashVerifySignatureReq *st = g_new0(FuStructLenovoDockFlashVerifySignatureReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_set_status: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_signature_req_set_status(FuStructLenovoDockFlashVerifySignatureReq *st, FuLenovoDockStatus value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_set_datasz: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_signature_req_set_datasz(FuStructLenovoDockFlashVerifySignatureReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_set_cmd_class: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_signature_req_set_cmd_class(FuStructLenovoDockFlashVerifySignatureReq *st, FuLenovoDockCmdClass value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_set_cmd_id: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_signature_req_set_cmd_id(FuStructLenovoDockFlashVerifySignatureReq *st, FuLenovoDockFlashCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_set_component_id: (skip):
 **/
void
fu_struct_lenovo_dock_flash_verify_signature_req_set_component_id(FuStructLenovoDockFlashVerifySignatureReq *st, FuLenovoDockComponentId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_set_type: (skip):
 **/
static void
fu_struct_lenovo_dock_flash_verify_signature_req_set_type(FuStructLenovoDockFlashVerifySignatureReq *st, FuLenovoDockFlashMemorySelfVerifyType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[6] = value;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_req_new: (skip):
 **/
FuStructLenovoDockFlashVerifySignatureReq *
fu_struct_lenovo_dock_flash_verify_signature_req_new(void)
{
    FuStructLenovoDockFlashVerifySignatureReq *st = fu_struct_lenovo_dock_flash_verify_signature_req_new_internal();
    st->buf = g_byte_array_sized_new(7);
    fu_byte_array_set_size(st->buf, 7, 0x0);
    fu_struct_lenovo_dock_flash_verify_signature_req_set_status(st, FU_LENOVO_DOCK_STATUS_DEFAULT);
    fu_struct_lenovo_dock_flash_verify_signature_req_set_datasz(st, 0x01);
    fu_struct_lenovo_dock_flash_verify_signature_req_set_cmd_class(st, FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH);
    fu_struct_lenovo_dock_flash_verify_signature_req_set_cmd_id(st, FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY);
    fu_struct_lenovo_dock_flash_verify_signature_req_set_type(st, FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_SIGNATURE);
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_ref: (skip):
 **/
FuStructLenovoDockFlashVerifySignatureRes *
fu_struct_lenovo_dock_flash_verify_signature_res_ref(FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_unref: (skip):
 **/
void
fu_struct_lenovo_dock_flash_verify_signature_res_unref(FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructLenovoDockFlashVerifySignatureRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_new_internal: (skip):
 **/
static FuStructLenovoDockFlashVerifySignatureRes *
fu_struct_lenovo_dock_flash_verify_signature_res_new_internal(void)
{
    FuStructLenovoDockFlashVerifySignatureRes *st = g_new0(FuStructLenovoDockFlashVerifySignatureRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_status: (skip):
 **/
static FuLenovoDockStatus
fu_struct_lenovo_dock_flash_verify_signature_res_get_status(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_datasz: (skip):
 **/
static guint8
fu_struct_lenovo_dock_flash_verify_signature_res_get_datasz(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class: (skip):
 **/
static FuLenovoDockCmdClass
fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id: (skip):
 **/
static FuLenovoDockFlashCmd
fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_component_id: (skip):
 **/
FuLenovoDockComponentId
fu_struct_lenovo_dock_flash_verify_signature_res_get_component_id(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_type: (skip):
 **/
static FuLenovoDockFlashMemorySelfVerifyType
fu_struct_lenovo_dock_flash_verify_signature_res_get_type(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_get_result: (skip):
 **/
FuLenovoDockFlashVerifySignatureResult
fu_struct_lenovo_dock_flash_verify_signature_res_get_result(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[7];
}

/* setters */
/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_to_string: (skip):
 **/
static gchar *
fu_struct_lenovo_dock_flash_verify_signature_res_to_string(const FuStructLenovoDockFlashVerifySignatureRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructLenovoDockFlashVerifySignatureRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_status(st));
        }
    }
    g_string_append_printf(str, "  datasz: 0x%x\n",
                           (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_datasz(st));
    {
        const gchar *tmp = fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_class: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_class: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_component_id_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_component_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_id: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_component_id(st), tmp);
        } else {
            g_string_append_printf(str, "  component_id: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_component_id(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_memory_self_verify_type_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  type: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_type(st), tmp);
        } else {
            g_string_append_printf(str, "  type: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_type(st));
        }
    }
    {
        const gchar *tmp = fu_lenovo_dock_flash_verify_signature_result_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_result(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  result: 0x%x [%s]\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_result(st), tmp);
        } else {
            g_string_append_printf(str, "  result: 0x%x\n", (guint) fu_struct_lenovo_dock_flash_verify_signature_res_get_result(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_lenovo_dock_flash_verify_signature_res_validate_internal(FuStructLenovoDockFlashVerifySignatureRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_lenovo_dock_flash_verify_signature_res_get_status(st) != FU_LENOVO_DOCK_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifySignatureRes.status was not valid, "
                    "expected 'FU_LENOVO_DOCK_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_signature_res_get_status(st),
                    fu_lenovo_dock_status_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_status(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_signature_res_get_datasz(st) != 0x02) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructLenovoDockFlashVerifySignatureRes.datasz was not valid");
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(st) != FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifySignatureRes.cmd_class was not valid, "
                    "expected 'FU_LENOVO_DOCK_CMD_CLASS_EXTERNAL_FLASH' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(st),
                    fu_lenovo_dock_cmd_class_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_class(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(st) != FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifySignatureRes.cmd_id was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_CMD_GET_FLASH_MEMORY_SELF_VERIFY' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(st),
                    fu_lenovo_dock_flash_cmd_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_cmd_id(st)));
        return FALSE;
    }
    if (fu_struct_lenovo_dock_flash_verify_signature_res_get_type(st) != FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_SIGNATURE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructLenovoDockFlashVerifySignatureRes.type was not valid, "
                    "expected 'FU_LENOVO_DOCK_FLASH_MEMORY_SELF_VERIFY_TYPE_SIGNATURE' and got 0x%x '%s'",
                    fu_struct_lenovo_dock_flash_verify_signature_res_get_type(st),
                    fu_lenovo_dock_flash_memory_self_verify_type_to_string(fu_struct_lenovo_dock_flash_verify_signature_res_get_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_lenovo_dock_flash_verify_signature_res_parse_internal(FuStructLenovoDockFlashVerifySignatureRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_lenovo_dock_flash_verify_signature_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_lenovo_dock_flash_verify_signature_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_lenovo_dock_flash_verify_signature_res_parse: (skip):
 **/
FuStructLenovoDockFlashVerifySignatureRes *
fu_struct_lenovo_dock_flash_verify_signature_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructLenovoDockFlashVerifySignatureRes) st = fu_struct_lenovo_dock_flash_verify_signature_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 8, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructLenovoDockFlashVerifySignatureRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 8);
    if (!fu_struct_lenovo_dock_flash_verify_signature_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
