carbon-tcomp-decoder 0.12.1

Rust decoder for Tensor cNFT Compressed program on Solana
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::PROGRAM_ID;
use crate::TcompDecoder;

pub mod bid;
pub mod buy;
pub mod buy_core;
pub mod buy_spl;
pub mod cancel_bid;
pub mod close_expired_bid;
pub mod close_expired_listing;
pub mod close_expired_listing_core;
pub mod delist;
pub mod delist_core;
pub mod edit;
pub mod list;
pub mod list_core;
pub mod take_bid_core;
pub mod take_bid_full_meta;
pub mod take_bid_legacy;
pub mod take_bid_meta_hash;
pub mod take_bid_t22;
pub mod take_bid_wns;
pub mod tcomp_noop;
pub mod withdraw_fees;

pub use self::bid::*;
pub use self::buy::*;
pub use self::buy_core::*;
pub use self::buy_spl::*;
pub use self::cancel_bid::*;
pub use self::close_expired_bid::*;
pub use self::close_expired_listing::*;
pub use self::close_expired_listing_core::*;
pub use self::delist::*;
pub use self::delist_core::*;
pub use self::edit::*;
pub use self::list::*;
pub use self::list_core::*;
pub use self::take_bid_core::*;
pub use self::take_bid_full_meta::*;
pub use self::take_bid_legacy::*;
pub use self::take_bid_meta_hash::*;
pub use self::take_bid_t22::*;
pub use self::take_bid_wns::*;
pub use self::tcomp_noop::*;
pub use self::withdraw_fees::*;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(
    feature = "serde",
    derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum TcompInstruction {
    Bid(Bid),
    Buy(Buy),
    BuyCore(BuyCore),
    BuySpl(BuySpl),
    CancelBid(CancelBid),
    CloseExpiredBid(CloseExpiredBid),
    CloseExpiredListing(CloseExpiredListing),
    CloseExpiredListingCore(CloseExpiredListingCore),
    Delist(Delist),
    DelistCore(DelistCore),
    Edit(Edit),
    List(List),
    ListCore(ListCore),
    TakeBidCore(TakeBidCore),
    TakeBidFullMeta(TakeBidFullMeta),
    TakeBidLegacy(TakeBidLegacy),
    TakeBidMetaHash(TakeBidMetaHash),
    TakeBidT22(TakeBidT22),
    TakeBidWns(TakeBidWns),
    TcompNoop(TcompNoop),
    WithdrawFees(WithdrawFees),
}

impl carbon_core::instruction::InstructionDecoder<'_> for TcompDecoder {
    type InstructionType = TcompInstruction;

    fn decode_instruction(
        &self,
        instruction: &solana_instruction::Instruction,
    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
        if !instruction.program_id.eq(&PROGRAM_ID) {
            return None;
        }

        let data = instruction.data.as_slice();

        {
            if let Some(decoded) = tcomp_noop::TcompNoop::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TcompNoop(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = withdraw_fees::WithdrawFees::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::WithdrawFees(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = buy::Buy::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::Buy(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = buy_spl::BuySpl::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::BuySpl(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = buy_core::BuyCore::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::BuyCore(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = list::List::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::List(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = delist::Delist::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::Delist(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = edit::Edit::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::Edit(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = list_core::ListCore::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::ListCore(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = delist_core::DelistCore::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::DelistCore(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = bid::Bid::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::Bid(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = cancel_bid::CancelBid::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::CancelBid(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = close_expired_bid::CloseExpiredBid::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::CloseExpiredBid(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = close_expired_listing::CloseExpiredListing::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::CloseExpiredListing(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = close_expired_listing_core::CloseExpiredListingCore::decode(data)
            {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::CloseExpiredListingCore(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = take_bid_meta_hash::TakeBidMetaHash::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TakeBidMetaHash(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = take_bid_full_meta::TakeBidFullMeta::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TakeBidFullMeta(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = take_bid_legacy::TakeBidLegacy::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TakeBidLegacy(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = take_bid_t22::TakeBidT22::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TakeBidT22(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = take_bid_wns::TakeBidWns::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TakeBidWns(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        {
            if let Some(decoded) = take_bid_core::TakeBidCore::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: TcompInstruction::TakeBidCore(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }

        None
    }
}