carbon-mpl-core-decoder 1.0.0

MPL Core Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::KeyGraphQL,
    carbon_core::graphql::primitives::{Pubkey, U32},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "CollectionV1")]
pub struct CollectionV1GraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub key: KeyGraphQL,
    pub update_authority: Pubkey,
    pub name: String,
    pub uri: String,
    pub num_minted: U32,
    pub current_size: U32,
}

impl TryFrom<crate::accounts::postgres::CollectionV1Row> for CollectionV1GraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::CollectionV1Row) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            key: row.key.0.into(),
            update_authority: carbon_core::graphql::primitives::Pubkey(row.update_authority.0),
            name: row.name,
            uri: row.uri,
            num_minted: carbon_core::graphql::primitives::U32((*row.num_minted) as u32),
            current_size: carbon_core::graphql::primitives::U32((*row.current_size) as u32),
        })
    }
}