carbon-drift-v2-decoder 2.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "OpenbookV2FulfillmentConfig")]
pub struct OpenbookV2FulfillmentConfigGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub pubkey: Pubkey,
    pub openbook_v2_program_id: Pubkey,
    pub openbook_v2_market: Pubkey,
    pub openbook_v2_market_authority: Pubkey,
    pub openbook_v2_event_heap: Pubkey,
    pub openbook_v2_bids: Pubkey,
    pub openbook_v2_asks: Pubkey,
    pub openbook_v2_base_vault: Pubkey,
    pub openbook_v2_quote_vault: Pubkey,
    pub market_index: i32,
    pub fulfillment_type: SpotFulfillmentTypeGraphQL,
    pub status: SpotFulfillmentConfigStatusGraphQL,
    pub padding: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::OpenbookV2FulfillmentConfigRow>
    for OpenbookV2FulfillmentConfigGraphQL
{
    type Error = carbon_core::error::Error;
    fn try_from(
        row: crate::accounts::postgres::OpenbookV2FulfillmentConfigRow,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            pubkey: carbon_core::graphql::primitives::Pubkey(row.pubkey.0),
            openbook_v2_program_id: carbon_core::graphql::primitives::Pubkey(
                row.openbook_v2_program_id.0,
            ),
            openbook_v2_market: carbon_core::graphql::primitives::Pubkey(row.openbook_v2_market.0),
            openbook_v2_market_authority: carbon_core::graphql::primitives::Pubkey(
                row.openbook_v2_market_authority.0,
            ),
            openbook_v2_event_heap: carbon_core::graphql::primitives::Pubkey(
                row.openbook_v2_event_heap.0,
            ),
            openbook_v2_bids: carbon_core::graphql::primitives::Pubkey(row.openbook_v2_bids.0),
            openbook_v2_asks: carbon_core::graphql::primitives::Pubkey(row.openbook_v2_asks.0),
            openbook_v2_base_vault: carbon_core::graphql::primitives::Pubkey(
                row.openbook_v2_base_vault.0,
            ),
            openbook_v2_quote_vault: carbon_core::graphql::primitives::Pubkey(
                row.openbook_v2_quote_vault.0,
            ),
            market_index: *row.market_index,
            fulfillment_type: row.fulfillment_type.0.into(),
            status: row.status.0.into(),
            padding: row
                .padding
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}