pub struct TailSeq<'a, T: SeqElement> { /* private fields */ }Expand description
Streaming read cursor over a Seq<T> tail region.
Borrows the tail-region bytes ([count:u32][elems...]) and decodes ONE
element per get / iterator step; it never builds a
[T; N]. Cheap to construct and copy.
Implementations§
Source§impl<'a, T: SeqElement> TailSeq<'a, T>
impl<'a, T: SeqElement> TailSeq<'a, T>
Sourcepub fn from_region(region: &'a [u8]) -> Result<Self, ProgramError>
pub fn from_region(region: &'a [u8]) -> Result<Self, ProgramError>
Overlay a read cursor on region (the tail bytes starting at the
count prefix). Rejects a region too small for the prefix, or a
stored count exceeding the region’s capacity (corrupt tail).
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Live element capacity from the region length: (len - 4) / STRIDE.
Sourcepub fn get(&self, index: usize) -> Result<T, ProgramError>
pub fn get(&self, index: usize) -> Result<T, ProgramError>
Decode the element at index (one element, no full-tail decode).
Sourcepub fn iter(&self) -> TailSeqIter<'a, T> ⓘ
pub fn iter(&self) -> TailSeqIter<'a, T> ⓘ
Iterate the live elements, decoding one at a time. Each item is a
Result because a corrupt slot can fail to decode (e.g. a bool
byte outside {0, 1}); a well-formed Seq yields only Ok.
Trait Implementations§
impl<'a, T: Copy + SeqElement> Copy for TailSeq<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for TailSeq<'a, T>where
PhantomData<T>: Freeze,
impl<'a, T> RefUnwindSafe for TailSeq<'a, T>where
PhantomData<T>: RefUnwindSafe,
impl<'a, T> Send for TailSeq<'a, T>where
PhantomData<T>: Send,
impl<'a, T> Sync for TailSeq<'a, T>where
PhantomData<T>: Sync,
impl<'a, T> Unpin for TailSeq<'a, T>where
PhantomData<T>: Unpin,
impl<'a, T> UnsafeUnpin for TailSeq<'a, T>where
PhantomData<T>: UnsafeUnpin,
impl<'a, T> UnwindSafe for TailSeq<'a, T>where
PhantomData<T>: UnwindSafe,
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