Skip to main content

carbon_token_program_decoder/instructions/
batch.rs

1//! This code was AUTOGENERATED using the Codama library.
2use {crate::types::BatchItem, carbon_core::deserialize::ArrangeAccounts};
3/// Executes a batch of instructions. The instructions to be executed are
4/// specified in sequence on the instruction data.
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
7pub struct Batch {
8    /// Instruction data for batch instructions.
9    pub data: Vec<BatchItem>,
10}
11
12#[derive(Debug, Clone, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub struct BatchInstructionAccounts {}
15
16impl Batch {
17    pub fn decode(data: &[u8]) -> Option<Self> {
18        if data.is_empty() {
19            return None;
20        }
21        let discriminator = &data[0..1];
22        if discriminator != [255] {
23            return None;
24        }
25
26        let mut data_slice = data;
27
28        data_slice = &data_slice[1..];
29
30        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
31    }
32}
33
34impl ArrangeAccounts for Batch {
35    type ArrangedAccounts = BatchInstructionAccounts;
36
37    fn arrange_accounts(
38        _accounts: &[solana_instruction::AccountMeta],
39    ) -> Option<Self::ArrangedAccounts> {
40        Some(BatchInstructionAccounts {})
41    }
42}