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

#include "config.h"

#include <glib.h>

#include "fu-rts54hub-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_rts54hub_vendor_cmd_to_string:
 * @val: value, e.g. %FU_RTS54HUB_VENDOR_CMD_ENABLE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 *
 **/
gchar *
fu_rts54hub_vendor_cmd_to_string(FuRts54hubVendorCmd val)
{
    const gchar *data[3] = {0};
    guint idx = 0;
    if (val == FU_RTS54HUB_VENDOR_CMD_NONE)
        return g_strdup("none");
    if (val & FU_RTS54HUB_VENDOR_CMD_ENABLE)
        data[idx++] = "enable";
    if (val & FU_RTS54HUB_VENDOR_CMD_ACCESS_FLASH)
        data[idx++] = "access-flash";
    return g_strjoinv(",", (gchar **)data);
}



/**
 * fu_struct_rts54_hub_ddc_pkt_ref: (skip):
 **/
FuStructRts54HubDdcPkt *
fu_struct_rts54_hub_ddc_pkt_ref(FuStructRts54HubDdcPkt *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_rts54_hub_ddc_pkt_unref: (skip):
 **/
void
fu_struct_rts54_hub_ddc_pkt_unref(FuStructRts54HubDdcPkt *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructRts54HubDdcPkt refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_rts54_hub_ddc_pkt_new_internal: (skip):
 **/
static FuStructRts54HubDdcPkt *
fu_struct_rts54_hub_ddc_pkt_new_internal(void)
{
    FuStructRts54HubDdcPkt *st = g_new0(FuStructRts54HubDdcPkt, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_rts54_hub_ddc_pkt_set_first_opcode: (skip):
 **/
void
fu_struct_rts54_hub_ddc_pkt_set_first_opcode(FuStructRts54HubDdcPkt *st, FuRts54HubMergeInfoDdcciOpcode value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_rts54_hub_ddc_pkt_set_second_opcode: (skip):
 **/
void
fu_struct_rts54_hub_ddc_pkt_set_second_opcode(FuStructRts54HubDdcPkt *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_rts54_hub_ddc_pkt_new: (skip):
 **/
FuStructRts54HubDdcPkt *
fu_struct_rts54_hub_ddc_pkt_new(void)
{
    FuStructRts54HubDdcPkt *st = fu_struct_rts54_hub_ddc_pkt_new_internal();
    st->buf = g_byte_array_sized_new(2);
    fu_byte_array_set_size(st->buf, 2, 0x0);
    fu_struct_rts54_hub_ddc_pkt_set_first_opcode(st, FU_RTS54_HUB_MERGE_INFO_DDCCI_OPCODE_FIRST);
    return st;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_ref: (skip):
 **/
FuStructRts54HubDdcWriteMergeInfoPkt *
fu_struct_rts54_hub_ddc_write_merge_info_pkt_ref(FuStructRts54HubDdcWriteMergeInfoPkt *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_unref: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_unref(FuStructRts54HubDdcWriteMergeInfoPkt *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructRts54HubDdcWriteMergeInfoPkt refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_new_internal: (skip):
 **/
static FuStructRts54HubDdcWriteMergeInfoPkt *
fu_struct_rts54_hub_ddc_write_merge_info_pkt_new_internal(void)
{
    FuStructRts54HubDdcWriteMergeInfoPkt *st = g_new0(FuStructRts54HubDdcWriteMergeInfoPkt, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_first_opcode: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_first_opcode(FuStructRts54HubDdcWriteMergeInfoPkt *st, FuRts54HubMergeInfoDdcciOpcode value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_second_opcode: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_second_opcode(FuStructRts54HubDdcWriteMergeInfoPkt *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_major_version: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_major_version(FuStructRts54HubDdcWriteMergeInfoPkt *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_minor_version: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_minor_version(FuStructRts54HubDdcWriteMergeInfoPkt *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_patch_version: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_patch_version(FuStructRts54HubDdcWriteMergeInfoPkt *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_build_version: (skip):
 **/
void
fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_build_version(FuStructRts54HubDdcWriteMergeInfoPkt *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_rts54_hub_ddc_write_merge_info_pkt_new: (skip):
 **/
FuStructRts54HubDdcWriteMergeInfoPkt *
fu_struct_rts54_hub_ddc_write_merge_info_pkt_new(void)
{
    FuStructRts54HubDdcWriteMergeInfoPkt *st = fu_struct_rts54_hub_ddc_write_merge_info_pkt_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_rts54_hub_ddc_write_merge_info_pkt_set_first_opcode(st, FU_RTS54_HUB_MERGE_INFO_DDCCI_OPCODE_FIRST);
    return st;
}
