carbon_crafting_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::CraftingDecoder;
3use crate::PROGRAM_ID;
4
5pub mod craftable_item;
6pub mod crafting_facility;
7pub mod crafting_process;
8pub mod domain;
9pub mod recipe;
10pub mod recipe_category;
11
12#[derive(Debug, Clone, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
15pub enum CraftingAccount {
16    CraftableItem(Box<craftable_item::CraftableItem>),
17    CraftingFacility(Box<crafting_facility::CraftingFacility>),
18    CraftingProcess(Box<crafting_process::CraftingProcess>),
19    Domain(Box<domain::Domain>),
20    Recipe(Box<recipe::Recipe>),
21    RecipeCategory(Box<recipe_category::RecipeCategory>),
22}
23
24impl<'a> carbon_core::account::AccountDecoder<'a> for CraftingDecoder {
25    type AccountType = CraftingAccount;
26
27    fn decode_account(
28        &self,
29        account: &'a solana_account::Account,
30    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
31        if account.owner != PROGRAM_ID {
32            return None;
33        }
34
35        let data = account.data.as_slice();
36
37        {
38            if let Some(decoded) = craftable_item::CraftableItem::decode(data) {
39                return Some(carbon_core::account::DecodedAccount {
40                    lamports: account.lamports,
41                    data: CraftingAccount::CraftableItem(Box::new(decoded)),
42                    owner: account.owner,
43                    executable: account.executable,
44                    rent_epoch: account.rent_epoch,
45                });
46            }
47        }
48        {
49            if let Some(decoded) = crafting_facility::CraftingFacility::decode(data) {
50                return Some(carbon_core::account::DecodedAccount {
51                    lamports: account.lamports,
52                    data: CraftingAccount::CraftingFacility(Box::new(decoded)),
53                    owner: account.owner,
54                    executable: account.executable,
55                    rent_epoch: account.rent_epoch,
56                });
57            }
58        }
59        {
60            if let Some(decoded) = crafting_process::CraftingProcess::decode(data) {
61                return Some(carbon_core::account::DecodedAccount {
62                    lamports: account.lamports,
63                    data: CraftingAccount::CraftingProcess(Box::new(decoded)),
64                    owner: account.owner,
65                    executable: account.executable,
66                    rent_epoch: account.rent_epoch,
67                });
68            }
69        }
70        {
71            if let Some(decoded) = domain::Domain::decode(data) {
72                return Some(carbon_core::account::DecodedAccount {
73                    lamports: account.lamports,
74                    data: CraftingAccount::Domain(Box::new(decoded)),
75                    owner: account.owner,
76                    executable: account.executable,
77                    rent_epoch: account.rent_epoch,
78                });
79            }
80        }
81        {
82            if let Some(decoded) = recipe::Recipe::decode(data) {
83                return Some(carbon_core::account::DecodedAccount {
84                    lamports: account.lamports,
85                    data: CraftingAccount::Recipe(Box::new(decoded)),
86                    owner: account.owner,
87                    executable: account.executable,
88                    rent_epoch: account.rent_epoch,
89                });
90            }
91        }
92        {
93            if let Some(decoded) = recipe_category::RecipeCategory::decode(data) {
94                return Some(carbon_core::account::DecodedAccount {
95                    lamports: account.lamports,
96                    data: CraftingAccount::RecipeCategory(Box::new(decoded)),
97                    owner: account.owner,
98                    executable: account.executable,
99                    rent_epoch: account.rent_epoch,
100                });
101            }
102        }
103
104        None
105    }
106}