carbon_tcomp_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::PROGRAM_ID;
3use crate::TcompDecoder;
4
5#[cfg(feature = "postgres")]
6pub mod postgres;
7
8#[cfg(feature = "graphql")]
9pub mod graphql;
10
11pub mod bid_state;
12pub mod list_state;
13
14#[derive(Debug, Clone, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
17pub enum TcompAccount {
18    BidState(Box<bid_state::BidState>),
19    ListState(Box<list_state::ListState>),
20}
21
22impl<'a> carbon_core::account::AccountDecoder<'a> for TcompDecoder {
23    type AccountType = TcompAccount;
24
25    fn decode_account(
26        &self,
27        account: &'a solana_account::Account,
28    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
29        if account.owner != PROGRAM_ID {
30            return None;
31        }
32
33        let data = account.data.as_slice();
34
35        {
36            if let Some(decoded) = list_state::ListState::decode(data) {
37                return Some(carbon_core::account::DecodedAccount {
38                    lamports: account.lamports,
39                    data: TcompAccount::ListState(Box::new(decoded)),
40                    owner: account.owner,
41                    executable: account.executable,
42                    rent_epoch: account.rent_epoch,
43                });
44            }
45        }
46        {
47            if let Some(decoded) = bid_state::BidState::decode(data) {
48                return Some(carbon_core::account::DecodedAccount {
49                    lamports: account.lamports,
50                    data: TcompAccount::BidState(Box::new(decoded)),
51                    owner: account.owner,
52                    executable: account.executable,
53                    rent_epoch: account.rent_epoch,
54                });
55            }
56        }
57
58        None
59    }
60}