carbon_sage_starbased_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::PROGRAM_ID;
3use crate::SageDecoder;
4
5pub mod crafting_instance;
6pub mod disbanded_fleet;
7pub mod fleet;
8pub mod fleet_ships;
9pub mod game;
10pub mod game_state;
11pub mod mine_item;
12pub mod planet;
13pub mod player_crew_record;
14pub mod progression_config;
15pub mod resource;
16pub mod sage_crew_config;
17pub mod sage_player_profile;
18pub mod sector;
19pub mod ship;
20pub mod star;
21pub mod starbase;
22pub mod starbase_player;
23pub mod survey_data_unit_tracker;
24
25#[derive(Debug, Clone, PartialEq)]
26#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
27#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
28pub enum SageAccount {
29    CraftingInstance(Box<crafting_instance::CraftingInstance>),
30    DisbandedFleet(Box<disbanded_fleet::DisbandedFleet>),
31    Fleet(Box<fleet::Fleet>),
32    FleetShips(Box<fleet_ships::FleetShips>),
33    Game(Box<game::Game>),
34    GameState(Box<game_state::GameState>),
35    MineItem(Box<mine_item::MineItem>),
36    Planet(Box<planet::Planet>),
37    PlayerCrewRecord(Box<player_crew_record::PlayerCrewRecord>),
38    ProgressionConfig(Box<progression_config::ProgressionConfig>),
39    Resource(Box<resource::Resource>),
40    SageCrewConfig(Box<sage_crew_config::SageCrewConfig>),
41    SagePlayerProfile(Box<sage_player_profile::SagePlayerProfile>),
42    Sector(Box<sector::Sector>),
43    Ship(Box<ship::Ship>),
44    Star(Box<star::Star>),
45    Starbase(Box<starbase::Starbase>),
46    StarbasePlayer(Box<starbase_player::StarbasePlayer>),
47    SurveyDataUnitTracker(Box<survey_data_unit_tracker::SurveyDataUnitTracker>),
48}
49
50impl<'a> carbon_core::account::AccountDecoder<'a> for SageDecoder {
51    type AccountType = SageAccount;
52
53    fn decode_account(
54        &self,
55        account: &'a solana_account::Account,
56    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
57        if account.owner != PROGRAM_ID {
58            return None;
59        }
60
61        let data = account.data.as_slice();
62
63        {
64            if let Some(decoded) = crafting_instance::CraftingInstance::decode(data) {
65                return Some(carbon_core::account::DecodedAccount {
66                    lamports: account.lamports,
67                    data: SageAccount::CraftingInstance(Box::new(decoded)),
68                    owner: account.owner,
69                    executable: account.executable,
70                    rent_epoch: account.rent_epoch,
71                });
72            }
73        }
74        {
75            if let Some(decoded) = disbanded_fleet::DisbandedFleet::decode(data) {
76                return Some(carbon_core::account::DecodedAccount {
77                    lamports: account.lamports,
78                    data: SageAccount::DisbandedFleet(Box::new(decoded)),
79                    owner: account.owner,
80                    executable: account.executable,
81                    rent_epoch: account.rent_epoch,
82                });
83            }
84        }
85        {
86            if let Some(decoded) = fleet::Fleet::decode(data) {
87                return Some(carbon_core::account::DecodedAccount {
88                    lamports: account.lamports,
89                    data: SageAccount::Fleet(Box::new(decoded)),
90                    owner: account.owner,
91                    executable: account.executable,
92                    rent_epoch: account.rent_epoch,
93                });
94            }
95        }
96        {
97            if let Some(decoded) = fleet_ships::FleetShips::decode(data) {
98                return Some(carbon_core::account::DecodedAccount {
99                    lamports: account.lamports,
100                    data: SageAccount::FleetShips(Box::new(decoded)),
101                    owner: account.owner,
102                    executable: account.executable,
103                    rent_epoch: account.rent_epoch,
104                });
105            }
106        }
107        {
108            if let Some(decoded) = game::Game::decode(data) {
109                return Some(carbon_core::account::DecodedAccount {
110                    lamports: account.lamports,
111                    data: SageAccount::Game(Box::new(decoded)),
112                    owner: account.owner,
113                    executable: account.executable,
114                    rent_epoch: account.rent_epoch,
115                });
116            }
117        }
118        {
119            if let Some(decoded) = game_state::GameState::decode(data) {
120                return Some(carbon_core::account::DecodedAccount {
121                    lamports: account.lamports,
122                    data: SageAccount::GameState(Box::new(decoded)),
123                    owner: account.owner,
124                    executable: account.executable,
125                    rent_epoch: account.rent_epoch,
126                });
127            }
128        }
129        {
130            if let Some(decoded) = mine_item::MineItem::decode(data) {
131                return Some(carbon_core::account::DecodedAccount {
132                    lamports: account.lamports,
133                    data: SageAccount::MineItem(Box::new(decoded)),
134                    owner: account.owner,
135                    executable: account.executable,
136                    rent_epoch: account.rent_epoch,
137                });
138            }
139        }
140        {
141            if let Some(decoded) = planet::Planet::decode(data) {
142                return Some(carbon_core::account::DecodedAccount {
143                    lamports: account.lamports,
144                    data: SageAccount::Planet(Box::new(decoded)),
145                    owner: account.owner,
146                    executable: account.executable,
147                    rent_epoch: account.rent_epoch,
148                });
149            }
150        }
151        {
152            if let Some(decoded) = player_crew_record::PlayerCrewRecord::decode(data) {
153                return Some(carbon_core::account::DecodedAccount {
154                    lamports: account.lamports,
155                    data: SageAccount::PlayerCrewRecord(Box::new(decoded)),
156                    owner: account.owner,
157                    executable: account.executable,
158                    rent_epoch: account.rent_epoch,
159                });
160            }
161        }
162        {
163            if let Some(decoded) = progression_config::ProgressionConfig::decode(data) {
164                return Some(carbon_core::account::DecodedAccount {
165                    lamports: account.lamports,
166                    data: SageAccount::ProgressionConfig(Box::new(decoded)),
167                    owner: account.owner,
168                    executable: account.executable,
169                    rent_epoch: account.rent_epoch,
170                });
171            }
172        }
173        {
174            if let Some(decoded) = resource::Resource::decode(data) {
175                return Some(carbon_core::account::DecodedAccount {
176                    lamports: account.lamports,
177                    data: SageAccount::Resource(Box::new(decoded)),
178                    owner: account.owner,
179                    executable: account.executable,
180                    rent_epoch: account.rent_epoch,
181                });
182            }
183        }
184        {
185            if let Some(decoded) = sage_crew_config::SageCrewConfig::decode(data) {
186                return Some(carbon_core::account::DecodedAccount {
187                    lamports: account.lamports,
188                    data: SageAccount::SageCrewConfig(Box::new(decoded)),
189                    owner: account.owner,
190                    executable: account.executable,
191                    rent_epoch: account.rent_epoch,
192                });
193            }
194        }
195        {
196            if let Some(decoded) = sage_player_profile::SagePlayerProfile::decode(data) {
197                return Some(carbon_core::account::DecodedAccount {
198                    lamports: account.lamports,
199                    data: SageAccount::SagePlayerProfile(Box::new(decoded)),
200                    owner: account.owner,
201                    executable: account.executable,
202                    rent_epoch: account.rent_epoch,
203                });
204            }
205        }
206        {
207            if let Some(decoded) = sector::Sector::decode(data) {
208                return Some(carbon_core::account::DecodedAccount {
209                    lamports: account.lamports,
210                    data: SageAccount::Sector(Box::new(decoded)),
211                    owner: account.owner,
212                    executable: account.executable,
213                    rent_epoch: account.rent_epoch,
214                });
215            }
216        }
217        {
218            if let Some(decoded) = ship::Ship::decode(data) {
219                return Some(carbon_core::account::DecodedAccount {
220                    lamports: account.lamports,
221                    data: SageAccount::Ship(Box::new(decoded)),
222                    owner: account.owner,
223                    executable: account.executable,
224                    rent_epoch: account.rent_epoch,
225                });
226            }
227        }
228        {
229            if let Some(decoded) = star::Star::decode(data) {
230                return Some(carbon_core::account::DecodedAccount {
231                    lamports: account.lamports,
232                    data: SageAccount::Star(Box::new(decoded)),
233                    owner: account.owner,
234                    executable: account.executable,
235                    rent_epoch: account.rent_epoch,
236                });
237            }
238        }
239        {
240            if let Some(decoded) = starbase::Starbase::decode(data) {
241                return Some(carbon_core::account::DecodedAccount {
242                    lamports: account.lamports,
243                    data: SageAccount::Starbase(Box::new(decoded)),
244                    owner: account.owner,
245                    executable: account.executable,
246                    rent_epoch: account.rent_epoch,
247                });
248            }
249        }
250        {
251            if let Some(decoded) = starbase_player::StarbasePlayer::decode(data) {
252                return Some(carbon_core::account::DecodedAccount {
253                    lamports: account.lamports,
254                    data: SageAccount::StarbasePlayer(Box::new(decoded)),
255                    owner: account.owner,
256                    executable: account.executable,
257                    rent_epoch: account.rent_epoch,
258                });
259            }
260        }
261        {
262            if let Some(decoded) = survey_data_unit_tracker::SurveyDataUnitTracker::decode(data) {
263                return Some(carbon_core::account::DecodedAccount {
264                    lamports: account.lamports,
265                    data: SageAccount::SurveyDataUnitTracker(Box::new(decoded)),
266                    owner: account.owner,
267                    executable: account.executable,
268                    rent_epoch: account.rent_epoch,
269                });
270            }
271        }
272
273        None
274    }
275}