Struct spl_type_length_value::state::TlvStateMut
source · pub struct TlvStateMut<'data> { /* private fields */ }Expand description
Encapsulates mutable base state data (mint or account) with possible extensions
Implementations§
source§impl<'data> TlvStateMut<'data>
impl<'data> TlvStateMut<'data>
sourcepub fn unpack(data: &'data mut [u8]) -> Result<Self, ProgramError>
pub fn unpack(data: &'data mut [u8]) -> Result<Self, ProgramError>
Unpacks TLV state data
Fails if no state is initialized or if data is too small
sourcepub fn get_value_mut<V: TlvDiscriminator + Pod>(
&mut self
) -> Result<&mut V, ProgramError>
pub fn get_value_mut<V: TlvDiscriminator + Pod>( &mut self ) -> Result<&mut V, ProgramError>
Unpack a portion of the TLV data as the desired type that allows modifying the type
sourcepub fn get_bytes_mut<V: TlvDiscriminator>(
&mut self
) -> Result<&mut [u8], ProgramError>
pub fn get_bytes_mut<V: TlvDiscriminator>( &mut self ) -> Result<&mut [u8], ProgramError>
Unpack a portion of the TLV data as mutable bytes
sourcepub fn init_value<V: TlvDiscriminator + Pod + Default>(
&mut self
) -> Result<&mut V, ProgramError>
pub fn init_value<V: TlvDiscriminator + Pod + Default>( &mut self ) -> Result<&mut V, ProgramError>
Packs the default TLV data into the first open slot in the data buffer. If extension is already found in the buffer, it returns an error.
sourcepub fn alloc<V: TlvDiscriminator>(
&mut self,
length: usize
) -> Result<&mut [u8], ProgramError>
pub fn alloc<V: TlvDiscriminator>( &mut self, length: usize ) -> Result<&mut [u8], ProgramError>
Allocate the given number of bytes for the given TlvDiscriminator
sourcepub fn realloc<V: TlvDiscriminator>(
&mut self,
length: usize
) -> Result<&mut [u8], ProgramError>
pub fn realloc<V: TlvDiscriminator>( &mut self, length: usize ) -> Result<&mut [u8], ProgramError>
Reallocate the given number of bytes for the given TlvDiscriminator. If the new length is smaller, it will compact the rest of the buffer and zero out the difference at the end. If it’s larger, it will move the rest of the buffer data and zero out the new data.
Trait Implementations§
source§impl<'data> Debug for TlvStateMut<'data>
impl<'data> Debug for TlvStateMut<'data>
source§impl<'data> PartialEq<TlvStateMut<'data>> for TlvStateMut<'data>
impl<'data> PartialEq<TlvStateMut<'data>> for TlvStateMut<'data>
source§fn eq(&self, other: &TlvStateMut<'data>) -> bool
fn eq(&self, other: &TlvStateMut<'data>) -> bool
self and other values to be equal, and is used
by ==.