core_preview/generated/accounts/
base_asset_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;
9use crate::generated::types::UpdateAuthority;
10use borsh::BorshDeserialize;
11use borsh::BorshSerialize;
12use solana_program::pubkey::Pubkey;
13
14#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16pub struct BaseAssetV1 {
17    pub key: Key,
18    #[cfg_attr(
19        feature = "serde",
20        serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
21    )]
22    pub owner: Pubkey,
23    pub update_authority: UpdateAuthority,
24    pub name: String,
25    pub uri: String,
26    pub seq: Option<u64>,
27}
28
29impl BaseAssetV1 {
30    #[inline(always)]
31    pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
32        let mut data = data;
33        Self::deserialize(&mut data)
34    }
35}
36
37impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for BaseAssetV1 {
38    type Error = std::io::Error;
39
40    fn try_from(
41        account_info: &solana_program::account_info::AccountInfo<'a>,
42    ) -> Result<Self, Self::Error> {
43        let mut data: &[u8] = &(*account_info.data).borrow();
44        Self::deserialize(&mut data)
45    }
46}