Skip to main content

List

Trait List 

Source
pub trait List: Deref<Target = [Self::Item]> {
    type Item: Pod;
    type Length: PodLength;

    // Required method
    fn capacity(&self) -> usize;

    // Provided methods
    fn bytes_used(&self) -> Result<usize, ProgramError> { ... }
    fn bytes_allocated(&self) -> Result<usize, ProgramError> { ... }
}
Expand description

A trait to abstract the shared, read-only behavior between ListViewReadOnly and ListViewMut.

Required Associated Types§

Source

type Item: Pod

The type of the items stored in the list.

Source

type Length: PodLength

Length prefix type used (PodU16, PodU32, …).

Required Methods§

Source

fn capacity(&self) -> usize

Returns the total number of items that can be stored in the list.

Provided Methods§

Source

fn bytes_used(&self) -> Result<usize, ProgramError>

Returns the number of bytes currently occupied by the live elements

Source

fn bytes_allocated(&self) -> Result<usize, ProgramError>

Returns the number of bytes reserved by the entire backing buffer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Pod, L: PodLength> List for ListViewMut<'_, T, L>

Source§

type Item = T

Source§

type Length = L

Source§

impl<T: Pod, L: PodLength> List for ListViewReadOnly<'_, T, L>

Source§

type Item = T

Source§

type Length = L