carbon-drift-v2-decoder 2.0.0

Drift v2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::CacheInfoGraphQL, carbon_core::graphql::primitives::U8,
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "AmmCache")]
pub struct AmmCacheGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub bump: U8,
    pub padding: Vec<U8>,
    pub cache: Vec<CacheInfoGraphQL>,
}

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