//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::graphql::primitives::{Pubkey, U64, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "SupportMintAssociated")]
pub struct SupportMintAssociatedGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub bump: U8,
    pub mint: Pubkey,
    pub padding: Vec<U64>,
}

impl TryFrom<crate::accounts::postgres::SupportMintAssociatedRow> for SupportMintAssociatedGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(
        row: crate::accounts::postgres::SupportMintAssociatedRow,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
            mint: carbon_core::graphql::primitives::Pubkey(row.mint.0),
            padding: row
                .padding
                .into_iter()
                .map(|item| carbon_core::graphql::primitives::U64(*item))
                .collect(),
        })
    }
}
