carbon-mpl-core-decoder 1.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "AssetV1")]
pub struct AssetV1GraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub key: KeyGraphQL,
    pub owner: Pubkey,
    pub update_authority: UpdateAuthorityGraphQL,
    pub name: String,
    pub uri: String,
    pub seq: Option<U64>,
}

impl TryFrom<crate::accounts::postgres::AssetV1Row> for AssetV1GraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::AssetV1Row) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            key: row.key.0.into(),
            owner: carbon_core::graphql::primitives::Pubkey(row.owner.0),
            update_authority: row.update_authority.0.into(),
            name: row.name,
            uri: row.uri,
            seq: row.seq.map(|v| carbon_core::graphql::primitives::U64(*v)),
        })
    }
}