carbon-mpl-token-metadata-decoder 1.0.0

MPL Token Metadata Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::{
        Collection, CollectionDetails, Data, Key, ProgrammableConfig, TokenStandard, Uses,
    },
    solana_pubkey::Pubkey,
};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct Metadata {
    pub key: Key,
    pub update_authority: Pubkey,
    pub mint: Pubkey,
    pub data: Data,
    pub primary_sale_happened: bool,
    pub is_mutable: bool,
    pub edition_nonce: Option<u8>,
    pub token_standard: Option<TokenStandard>,
    pub collection: Option<Collection>,
    pub uses: Option<Uses>,
    pub collection_details: Option<CollectionDetails>,
    pub programmable_config: Option<ProgrammableConfig>,
}

impl Metadata {
    pub fn decode(data: &[u8]) -> Option<Self> {
        let mut data_slice = data;

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}