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