carbon-zeta-decoder 1.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PerpSyncQueue")]
pub struct PerpSyncQueueGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub nonce: U8,
    pub head: i32,
    pub length: i32,
    pub queue: Vec<AnchorDecimalGraphQL>,
}

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