carbon-zeta-decoder 2.0.0

Zeta Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::CrossMarginAccountInfoGraphQL,
    carbon_core::graphql::primitives::{Pubkey, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "CrossMarginAccountManager")]
pub struct CrossMarginAccountManagerGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub nonce: U8,
    pub authority: Pubkey,
    pub accounts: Vec<CrossMarginAccountInfoGraphQL>,
}

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