mpl_core/generated/accounts/
base_collection_v1.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! [https://github.com/metaplex-foundation/kinobi]
6//!
7
8use crate::generated::types::Key;
9#[cfg(feature = "anchor")]
10use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
11#[cfg(not(feature = "anchor"))]
12use borsh::{BorshDeserialize, BorshSerialize};
13use solana_program::pubkey::Pubkey;
14
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
17#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
18#[derive(Clone, Debug, Eq, PartialEq)]
19pub struct BaseCollectionV1 {
20    pub key: Key,
21    #[cfg_attr(
22        feature = "serde",
23        serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
24    )]
25    pub update_authority: Pubkey,
26    pub name: String,
27    pub uri: String,
28    pub num_minted: u32,
29    pub current_size: u32,
30}
31
32impl BaseCollectionV1 {
33    #[inline(always)]
34    pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
35        let mut data = data;
36        Self::deserialize(&mut data)
37    }
38}
39
40impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for BaseCollectionV1 {
41    type Error = std::io::Error;
42
43    fn try_from(
44        account_info: &solana_program::account_info::AccountInfo<'a>,
45    ) -> Result<Self, Self::Error> {
46        let mut data: &[u8] = &(*account_info.data).borrow();
47        Self::deserialize(&mut data)
48    }
49}