pub struct ZeroCopy<T>(pub T);Expand description
Workaround for deserializing zero-copy accounts.
Tuple Fields§
§0: TImplementations§
Source§impl<T> ZeroCopy<T>
impl<T> ZeroCopy<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Conver into inner value.
Trait Implementations§
Source§impl<T> AccountDeserialize for ZeroCopy<T>where
T: ZeroCopy,
impl<T> AccountDeserialize for ZeroCopy<T>where
T: ZeroCopy,
Source§fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
Deserializes previously initialized account data. Should fail for all
uninitialized accounts, where the bytes are zeroed. Implementations
should be unique to a particular account type so that one can never
successfully deserialize the data of one account type into another.
For example, if the SPL token program were to implement this trait,
it should be impossible to deserialize a
Mint account into a token
Account.Source§fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>
Deserializes account data without checking the account discriminator.
This should only be used on account initialization, when the bytes of
the account are zeroed.
Source§impl<T> Discriminator for ZeroCopy<T>where
T: Discriminator,
impl<T> Discriminator for ZeroCopy<T>where
T: Discriminator,
const DISCRIMINATOR: [u8; 8] = T::DISCRIMINATOR
fn discriminator() -> [u8; 8]
impl<T: Copy> Copy for ZeroCopy<T>
Auto Trait Implementations§
impl<T> Freeze for ZeroCopy<T>where
T: Freeze,
impl<T> RefUnwindSafe for ZeroCopy<T>where
T: RefUnwindSafe,
impl<T> Send for ZeroCopy<T>where
T: Send,
impl<T> Sync for ZeroCopy<T>where
T: Sync,
impl<T> Unpin for ZeroCopy<T>where
T: Unpin,
impl<T> UnwindSafe for ZeroCopy<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'info, T> Lamports<'info> for Twhere
T: AsRef<AccountInfo<'info>>,
impl<'info, T> Lamports<'info> for Twhere
T: AsRef<AccountInfo<'info>>,
§fn get_lamports(&self) -> u64
fn get_lamports(&self) -> u64
Get the lamports of the account.
§fn add_lamports(&self, amount: u64) -> Result<&Self, Error>
fn add_lamports(&self, amount: u64) -> Result<&Self, Error>
Add lamports to the account. Read more
§fn sub_lamports(&self, amount: u64) -> Result<&Self, Error>
fn sub_lamports(&self, amount: u64) -> Result<&Self, Error>
Subtract lamports from the account. Read more