carbon-sharky-decoder 2.0.0

Sharky Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::{APYGraphQL, BookLoanTermsGraphQL, OrderBookTypeGraphQL},
    carbon_core::graphql::primitives::{Pubkey, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "OrderBook")]
pub struct OrderBookGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub version: U8,
    pub order_book_type: OrderBookTypeGraphQL,
    pub apy: APYGraphQL,
    pub loan_terms: BookLoanTermsGraphQL,
    pub fee_permillicentage: i32,
    pub fee_authority: Pubkey,
}

impl TryFrom<crate::accounts::postgres::OrderBookRow> for OrderBookGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::OrderBookRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            version: carbon_core::graphql::primitives::U8((*row.version) as u8),
            order_book_type: row.order_book_type.0.into(),
            apy: row.apy.0.into(),
            loan_terms: row.loan_terms.0.into(),
            fee_permillicentage: *row.fee_permillicentage,
            fee_authority: carbon_core::graphql::primitives::Pubkey(row.fee_authority.0),
        })
    }
}