carbon-openbook-v2-decoder 2.0.0

Openbook V2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::{EventHeapHeaderGraphQL, EventNodeGraphQL},
    carbon_core::graphql::primitives::U8,
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "EventHeap")]
pub struct EventHeapGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub header: EventHeapHeaderGraphQL,
    pub nodes: Vec<EventNodeGraphQL>,
    pub reserved: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::EventHeapRow> for EventHeapGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::EventHeapRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            header: row.header.0.into(),
            nodes: row.nodes.0.into_iter().map(|item| item.into()).collect(),
            reserved: row
                .reserved
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}