carbon-marginfi-v2-decoder 1.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "BankMetadata")]
pub struct BankMetadataGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub bank: Pubkey,
    pub placeholder: U64,
    pub ticker: Vec<U8>,
    pub description: Vec<U8>,
    pub data_blob: Vec<U8>,
    pub end_description_byte: i32,
    pub end_data_blob: i32,
    pub end_ticker_byte: U8,
    pub bump: U8,
    pub pad0: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::BankMetadataRow> for BankMetadataGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::BankMetadataRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            bank: carbon_core::graphql::primitives::Pubkey(row.bank.0),
            placeholder: carbon_core::graphql::primitives::U64(*row.placeholder),
            ticker: row
                .ticker
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
            description: row
                .description
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
            data_blob: row
                .data_blob
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
            end_description_byte: *row.end_description_byte,
            end_data_blob: *row.end_data_blob,
            end_ticker_byte: carbon_core::graphql::primitives::U8((*row.end_ticker_byte) as u8),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
            pad0: row
                .pad0
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}