carbon_token_2022_decoder/instructions/
get_account_data_size.rs

1//! This code was AUTOGENERATED using the Codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun Codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7use carbon_core::account_utils::next_account;
8use carbon_core::borsh;
9use carbon_core::deserialize::ArrangeAccounts;
10use carbon_core::deserialize::CarbonDeserialize;
11use carbon_core::CarbonDeserialize;
12
13/// Gets the required size of an account for the given mint as a
14/// little-endian `u64`.
15///
16/// Return data can be fetched using `sol_get_return_data` and deserializing
17/// the return data as a little-endian `u64`.
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
20pub struct GetAccountDataSize {}
21
22#[derive(Debug, Clone, PartialEq)]
23#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
24pub struct GetAccountDataSizeInstructionAccounts {
25    pub mint: solana_pubkey::Pubkey,
26    pub remaining: Vec<solana_instruction::AccountMeta>,
27}
28
29impl GetAccountDataSize {
30    pub fn decode(data: &[u8]) -> Option<Self> {
31        if data.is_empty() {
32            return None;
33        }
34        let discriminator = &data[0..1];
35        if discriminator != [21] {
36            return None;
37        }
38
39        let data_slice = data;
40
41        let data_slice = &data_slice[1..];
42
43        Self::deserialize(data_slice)
44    }
45}
46
47impl ArrangeAccounts for GetAccountDataSize {
48    type ArrangedAccounts = GetAccountDataSizeInstructionAccounts;
49
50    fn arrange_accounts(
51        accounts: &[solana_instruction::AccountMeta],
52    ) -> Option<Self::ArrangedAccounts> {
53        let mut iter = accounts.iter();
54
55        let mint = next_account(&mut iter)?;
56
57        let remaining = iter.as_slice();
58
59        Some(GetAccountDataSizeInstructionAccounts {
60            mint,
61            remaining: remaining.to_vec(),
62        })
63    }
64}