carbon-drift-v2-decoder 2.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ConstituentCorrelations")]
pub struct ConstituentCorrelationsGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub lp_pool: Pubkey,
    pub bump: U8,
    pub padding: Vec<U8>,
    pub correlations: Vec<I64>,
}

impl TryFrom<crate::accounts::postgres::ConstituentCorrelationsRow>
    for ConstituentCorrelationsGraphQL
{
    type Error = carbon_core::error::Error;
    fn try_from(
        row: crate::accounts::postgres::ConstituentCorrelationsRow,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            lp_pool: carbon_core::graphql::primitives::Pubkey(row.lp_pool.0),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
            padding: row
                .padding
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
            correlations: row
                .correlations
                .into_iter()
                .map(carbon_core::graphql::primitives::I64)
                .collect(),
        })
    }
}