mpl_core/generated/accounts/
hashed_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;
9#[cfg(feature = "anchor")]
10use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
11#[cfg(not(feature = "anchor"))]
12use borsh::{BorshDeserialize, BorshSerialize};
13
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
16#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
17#[derive(Clone, Debug, Eq, PartialEq)]
18pub struct HashedAssetV1 {
19    pub key: Key,
20    pub hash: [u8; 32],
21}
22
23impl HashedAssetV1 {
24    pub const LEN: usize = 33;
25
26    #[inline(always)]
27    pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
28        let mut data = data;
29        Self::deserialize(&mut data)
30    }
31}
32
33impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for HashedAssetV1 {
34    type Error = std::io::Error;
35
36    fn try_from(
37        account_info: &solana_program::account_info::AccountInfo<'a>,
38    ) -> Result<Self, Self::Error> {
39        let mut data: &[u8] = &(*account_info.data).borrow();
40        Self::deserialize(&mut data)
41    }
42}