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

#include "fu-algoltek-usb-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"

/* getters */
/**
 * fu_struct_algoltek_product_identity_get_header_len: (skip):
 **/
guint8
fu_struct_algoltek_product_identity_get_header_len(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->data[0];
}
/**
 * fu_struct_algoltek_product_identity_get_header: (skip):
 **/
static guint64
fu_struct_algoltek_product_identity_get_header(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint64(st->data + 1, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_algoltek_product_identity_get_product_name_len: (skip):
 **/
guint8
fu_struct_algoltek_product_identity_get_product_name_len(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->data[9];
}
/**
 * fu_struct_algoltek_product_identity_get_product_name: (skip):
 **/
gchar *
fu_struct_algoltek_product_identity_get_product_name(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    return fu_memstrsafe(st->data, st->len, 10, 16, NULL);
}
/**
 * fu_struct_algoltek_product_identity_get_version_len: (skip):
 **/
guint8
fu_struct_algoltek_product_identity_get_version_len(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->data[26];
}
/**
 * fu_struct_algoltek_product_identity_get_version: (skip):
 **/
gchar *
fu_struct_algoltek_product_identity_get_version(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    return fu_memstrsafe(st->data, st->len, 27, 48, NULL);
}

/* setters */
/**
 * fu_struct_algoltek_product_identity_validate: (skip):
 **/
static gboolean
fu_struct_algoltek_product_identity_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    GByteArray st = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    if (!fu_memchk_read(bufsz, offset, 75, error)) {
        g_prefix_error(error, "invalid struct AlgoltekProductIdentity: ");
        return FALSE;
    }
    if (fu_struct_algoltek_product_identity_get_header(&st) != 0x4B45544C4F474C41) {
        g_set_error_literal(error,
                            G_IO_ERROR,
                            G_IO_ERROR_INVALID_DATA,
                            "constant AlgoltekProductIdentity.header was not valid");
        return FALSE;
    }
    return TRUE;
}
/**
 * fu_struct_algoltek_product_identity_validate_bytes: (skip):
 **/
gboolean
fu_struct_algoltek_product_identity_validate_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = g_bytes_get_data(blob, &bufsz);
    return fu_struct_algoltek_product_identity_validate(buf, bufsz, offset, error);
}
/* getters */

/* setters */
/**
 * fu_struct_algoltek_cmd_address_pkt_set_len: (skip):
 **/
void
fu_struct_algoltek_cmd_address_pkt_set_len(GByteArray *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->data[0] = value;
}
/**
 * fu_struct_algoltek_cmd_address_pkt_set_cmd: (skip):
 **/
void
fu_struct_algoltek_cmd_address_pkt_set_cmd(GByteArray *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->data[1] = value;
}
/**
 * fu_struct_algoltek_cmd_address_pkt_set_address: (skip):
 **/
void
fu_struct_algoltek_cmd_address_pkt_set_address(GByteArray *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_algoltek_cmd_address_pkt_set_value: (skip):
 **/
void
fu_struct_algoltek_cmd_address_pkt_set_value(GByteArray *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->data + 4, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_algoltek_cmd_address_pkt_set_checksum: (skip):
 **/
void
fu_struct_algoltek_cmd_address_pkt_set_checksum(GByteArray *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->data[10] = value;
}
/**
 * fu_struct_algoltek_cmd_address_pkt_new: (skip):
 **/
GByteArray *
fu_struct_algoltek_cmd_address_pkt_new(void)
{
    GByteArray *st = g_byte_array_sized_new(11);
    fu_byte_array_set_size(st, 11, 0x0);
    return st;
}
/* getters */

/* setters */
/**
 * fu_struct_algoltek_cmd_transfer_pkt_set_len: (skip):
 **/
void
fu_struct_algoltek_cmd_transfer_pkt_set_len(GByteArray *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->data[0] = value;
}
/**
 * fu_struct_algoltek_cmd_transfer_pkt_set_cmd: (skip):
 **/
void
fu_struct_algoltek_cmd_transfer_pkt_set_cmd(GByteArray *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->data[1] = value;
}
/**
 * fu_struct_algoltek_cmd_transfer_pkt_set_address: (skip):
 **/
void
fu_struct_algoltek_cmd_transfer_pkt_set_address(GByteArray *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_algoltek_cmd_transfer_pkt_set_data: (skip):
 **/
gboolean
fu_struct_algoltek_cmd_transfer_pkt_set_data(GByteArray *st, const guint8 *buf, gsize bufsz, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    return fu_memcpy_safe(st->data, st->len, 4, buf, bufsz, 0x0, bufsz, error);
}
/**
 * fu_struct_algoltek_cmd_transfer_pkt_set_checksum: (skip):
 **/
void
fu_struct_algoltek_cmd_transfer_pkt_set_checksum(GByteArray *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->data[65] = value;
}
/**
 * fu_struct_algoltek_cmd_transfer_pkt_new: (skip):
 **/
GByteArray *
fu_struct_algoltek_cmd_transfer_pkt_new(void)
{
    GByteArray *st = g_byte_array_sized_new(66);
    fu_byte_array_set_size(st, 66, 0x0);
    return st;
}
