pub struct BigVec<'data> {
pub data: &'data mut [u8],
}Expand description
Contains easy to use utilities for a big vector of Borsh-compatible types, to avoid managing the entire struct on-chain and blow through stack limits.
Fields§
§data: &'data mut [u8]Underlying data buffer, pieces of which are serialized
Implementations§
Source§impl BigVec<'_>
impl BigVec<'_>
Sourcepub fn retain<T: Pod, F: Fn(&[u8]) -> bool>(
&mut self,
predicate: F,
) -> Result<(), ProgramError>
pub fn retain<T: Pod, F: Fn(&[u8]) -> bool>( &mut self, predicate: F, ) -> Result<(), ProgramError>
Retain all elements that match the provided function, discard all others
Sourcepub fn deserialize_mut_slice<T: Pod>(
&mut self,
skip: usize,
len: usize,
) -> Result<&mut [T], ProgramError>
pub fn deserialize_mut_slice<T: Pod>( &mut self, skip: usize, len: usize, ) -> Result<&mut [T], ProgramError>
Extracts a slice of the data types
Sourcepub fn deserialize_slice<T: Pod>(
&self,
skip: usize,
len: usize,
) -> Result<&[T], ProgramError>
pub fn deserialize_slice<T: Pod>( &self, skip: usize, len: usize, ) -> Result<&[T], ProgramError>
Extracts a slice of the data types
Sourcepub fn push<T: Pod>(&mut self, element: T) -> Result<(), ProgramError>
pub fn push<T: Pod>(&mut self, element: T) -> Result<(), ProgramError>
Add new element to the end
Auto Trait Implementations§
impl<'data> Freeze for BigVec<'data>
impl<'data> RefUnwindSafe for BigVec<'data>
impl<'data> Send for BigVec<'data>
impl<'data> Sync for BigVec<'data>
impl<'data> Unpin for BigVec<'data>
impl<'data> !UnwindSafe for BigVec<'data>
Blanket Implementations§
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> 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