/* auto-generated, do not modify */
#include "config.h"

#include "fu-logitech-bulkcontroller-struct.h"
#include "fu-byte-array.h"
#include "fu-mem-private.h"
#include "fu-string.h"

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

const gchar *
fu_logitech_bulkcontroller_device_state_to_string(FuLogitechBulkcontrollerDeviceState val)
{
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_UNKNOWN)
        return "unknown";
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_OFFLINE)
        return "offline";
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_ONLINE)
        return "online";
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_IDLE)
        return "idle";
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_IN_USE)
        return "in-use";
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_AUDIO_ONLY)
        return "audio-only";
    if (val == FU_LOGITECH_BULKCONTROLLER_DEVICE_STATE_ENUMERATING)
        return "enumerating";
    return NULL;
}

const gchar *
fu_logitech_bulkcontroller_update_state_to_string(FuLogitechBulkcontrollerUpdateState val)
{
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_UNKNOWN)
        return "unknown";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_CURRENT)
        return "current";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_AVAILABLE)
        return "available";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_STARTING)
        return "starting";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_DOWNLOADING)
        return "downloading";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_READY)
        return "ready";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_UPDATING)
        return "updating";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_SCHEDULED)
        return "scheduled";
    if (val == FU_LOGITECH_BULKCONTROLLER_UPDATE_STATE_ERROR)
        return "error";
    return NULL;
}

const gchar *
fu_logitech_bulkcontroller_cmd_to_string(FuLogitechBulkcontrollerCmd val)
{
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_CHECK_BUFFERSIZE)
        return "check-buffersize";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_INIT)
        return "init";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_START_TRANSFER)
        return "start-transfer";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_DATA_TRANSFER)
        return "data-transfer";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_END_TRANSFER)
        return "end-transfer";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_UNINIT)
        return "uninit";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_BUFFER_READ)
        return "buffer-read";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_BUFFER_WRITE)
        return "buffer-write";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_UNINIT_BUFFER)
        return "uninit-buffer";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_ACK)
        return "ack";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_TIMEOUT)
        return "timeout";
    if (val == FU_LOGITECH_BULKCONTROLLER_CMD_NACK)
        return "nack";
    return NULL;
}

/* getters */
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_get_cmd: (skip):
 **/
FuLogitechBulkcontrollerCmd
fu_struct_logitech_bulkcontroller_send_sync_req_get_cmd(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_get_payload_length: (skip):
 **/
guint32
fu_struct_logitech_bulkcontroller_send_sync_req_get_payload_length(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_get_sequence_id: (skip):
 **/
guint32
fu_struct_logitech_bulkcontroller_send_sync_req_get_sequence_id(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_set_cmd: (skip):
 **/
void
fu_struct_logitech_bulkcontroller_send_sync_req_set_cmd(GByteArray *st, FuLogitechBulkcontrollerCmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_set_payload_length: (skip):
 **/
void
fu_struct_logitech_bulkcontroller_send_sync_req_set_payload_length(GByteArray *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_set_sequence_id: (skip):
 **/
void
fu_struct_logitech_bulkcontroller_send_sync_req_set_sequence_id(GByteArray *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_new: (skip):
 **/
GByteArray *
fu_struct_logitech_bulkcontroller_send_sync_req_new(void)
{
    GByteArray *st = g_byte_array_sized_new(12);
    fu_byte_array_set_size(st, 12, 0x0);
    return st;
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_req_to_string: (skip):
 **/
gchar *
fu_struct_logitech_bulkcontroller_send_sync_req_to_string(const GByteArray *st)
{
    g_autoptr(GString) str = g_string_new("LogitechBulkcontrollerSendSyncReq:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_logitech_bulkcontroller_cmd_to_string(fu_struct_logitech_bulkcontroller_send_sync_req_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_logitech_bulkcontroller_send_sync_req_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_logitech_bulkcontroller_send_sync_req_get_cmd(st));
        }
    }
    g_string_append_printf(str, "  payload_length: 0x%x\n",
                           (guint) fu_struct_logitech_bulkcontroller_send_sync_req_get_payload_length(st));
    g_string_append_printf(str, "  sequence_id: 0x%x\n",
                           (guint) fu_struct_logitech_bulkcontroller_send_sync_req_get_sequence_id(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/* getters */
/**
 * fu_struct_logitech_bulkcontroller_send_sync_res_get_cmd: (skip):
 **/
FuLogitechBulkcontrollerCmd
fu_struct_logitech_bulkcontroller_send_sync_res_get_cmd(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_res_get_payload_length: (skip):
 **/
guint32
fu_struct_logitech_bulkcontroller_send_sync_res_get_payload_length(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_send_sync_res_get_sequence_id: (skip):
 **/
guint32
fu_struct_logitech_bulkcontroller_send_sync_res_get_sequence_id(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_logitech_bulkcontroller_send_sync_res_to_string: (skip):
 **/
static gchar *
fu_struct_logitech_bulkcontroller_send_sync_res_to_string(const GByteArray *st)
{
    g_autoptr(GString) str = g_string_new("LogitechBulkcontrollerSendSyncRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_logitech_bulkcontroller_cmd_to_string(fu_struct_logitech_bulkcontroller_send_sync_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_logitech_bulkcontroller_send_sync_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_logitech_bulkcontroller_send_sync_res_get_cmd(st));
        }
    }
    g_string_append_printf(str, "  payload_length: 0x%x\n",
                           (guint) fu_struct_logitech_bulkcontroller_send_sync_res_get_payload_length(st));
    g_string_append_printf(str, "  sequence_id: 0x%x\n",
                           (guint) fu_struct_logitech_bulkcontroller_send_sync_res_get_sequence_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_logitech_bulkcontroller_send_sync_res_parse: (skip):
 **/
GByteArray *
fu_struct_logitech_bulkcontroller_send_sync_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(GByteArray) st = g_byte_array_new();
    g_autofree gchar *str = NULL;
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 12, error)) {
        g_prefix_error(error, "invalid struct LogitechBulkcontrollerSendSyncRes: ");
        return NULL;
    }
    g_byte_array_append(st, buf + offset, 12);
    str = fu_struct_logitech_bulkcontroller_send_sync_res_to_string(st);
    g_debug("%s", str);
    return g_steal_pointer(&st);
}
/* getters */

/* setters */
/**
 * fu_struct_logitech_bulkcontroller_update_req_set_cmd: (skip):
 **/
void
fu_struct_logitech_bulkcontroller_update_req_set_cmd(GByteArray *st, FuLogitechBulkcontrollerCmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_update_req_set_payload_length: (skip):
 **/
void
fu_struct_logitech_bulkcontroller_update_req_set_payload_length(GByteArray *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_update_req_new: (skip):
 **/
GByteArray *
fu_struct_logitech_bulkcontroller_update_req_new(void)
{
    GByteArray *st = g_byte_array_sized_new(8);
    fu_byte_array_set_size(st, 8, 0x0);
    return st;
}
/* getters */
/**
 * fu_struct_logitech_bulkcontroller_update_res_get_cmd: (skip):
 **/
FuLogitechBulkcontrollerCmd
fu_struct_logitech_bulkcontroller_update_res_get_cmd(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_logitech_bulkcontroller_update_res_get_cmd_req: (skip):
 **/
FuLogitechBulkcontrollerCmd
fu_struct_logitech_bulkcontroller_update_res_get_cmd_req(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
}

/* setters */
