Skip to main content

ListReader

Struct ListReader 

Source
pub struct ListReader<'b, 'r> { /* private fields */ }

Implementations§

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn len(&self) -> u32

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, index: u32) -> Result<Ref<'b, 'r>>

Source

pub fn iter(&self) -> impl Iterator<Item = Result<Ref<'b, 'r>>> + '_

Source

pub fn as_u8_slice(&self) -> Result<&'b [u8]>

Borrow a list<u8> as a slice of the message buffer — no copy, no conversion.

u8 is the one numeric element type with no endianness and no alignment to satisfy, so it is the only one that can be handed back as a borrow. Every wider type needs a little-endian decode, which safe Rust cannot do in place; use the copy_* / to_vec_* methods for those.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_u8(&self, out: &mut [u8]) -> Result<usize>

Bulk-copy a u8 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_u8(&self) -> Result<Vec<u8>>

Read a whole u8 list into a new Vec.

Allocates once, at the exact length. Prefer copy_u8 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_u16(&self, out: &mut [u16]) -> Result<usize>

Bulk-copy a u16 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_u16(&self) -> Result<Vec<u16>>

Read a whole u16 list into a new Vec.

Allocates once, at the exact length. Prefer copy_u16 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_u32(&self, out: &mut [u32]) -> Result<usize>

Bulk-copy a u32 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_u32(&self) -> Result<Vec<u32>>

Read a whole u32 list into a new Vec.

Allocates once, at the exact length. Prefer copy_u32 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_u64(&self, out: &mut [u64]) -> Result<usize>

Bulk-copy a u64 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_u64(&self) -> Result<Vec<u64>>

Read a whole u64 list into a new Vec.

Allocates once, at the exact length. Prefer copy_u64 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_i8(&self, out: &mut [i8]) -> Result<usize>

Bulk-copy a i8 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_i8(&self) -> Result<Vec<i8>>

Read a whole i8 list into a new Vec.

Allocates once, at the exact length. Prefer copy_i8 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_i16(&self, out: &mut [i16]) -> Result<usize>

Bulk-copy a i16 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_i16(&self) -> Result<Vec<i16>>

Read a whole i16 list into a new Vec.

Allocates once, at the exact length. Prefer copy_i16 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_i32(&self, out: &mut [i32]) -> Result<usize>

Bulk-copy a i32 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_i32(&self) -> Result<Vec<i32>>

Read a whole i32 list into a new Vec.

Allocates once, at the exact length. Prefer copy_i32 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_i64(&self, out: &mut [i64]) -> Result<usize>

Bulk-copy a i64 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_i64(&self) -> Result<Vec<i64>>

Read a whole i64 list into a new Vec.

Allocates once, at the exact length. Prefer copy_i64 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_f32(&self, out: &mut [f32]) -> Result<usize>

Bulk-copy a f32 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_f32(&self) -> Result<Vec<f32>>

Read a whole f32 list into a new Vec.

Allocates once, at the exact length. Prefer copy_f32 with a reused buffer on a hot path.

Source§

impl<'b, 'r> ListReader<'b, 'r>

Source

pub fn copy_f64(&self, out: &mut [f64]) -> Result<usize>

Bulk-copy a f64 list into out, returning how many elements were written.

Copies min(len(), out.len()) elements — a short out is not an error, so a caller can read a prefix deliberately.

Source

pub fn to_vec_f64(&self) -> Result<Vec<f64>>

Read a whole f64 list into a new Vec.

Allocates once, at the exact length. Prefer copy_f64 with a reused buffer on a hot path.

Trait Implementations§

Source§

impl<'b, 'r> Clone for ListReader<'b, 'r>

Source§

fn clone(&self) -> ListReader<'b, 'r>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'b, 'r> Debug for ListReader<'b, 'r>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b, 'r> !RefUnwindSafe for ListReader<'b, 'r>

§

impl<'b, 'r> !Send for ListReader<'b, 'r>

§

impl<'b, 'r> !Sync for ListReader<'b, 'r>

§

impl<'b, 'r> !UnwindSafe for ListReader<'b, 'r>

§

impl<'b, 'r> Freeze for ListReader<'b, 'r>

§

impl<'b, 'r> Unpin for ListReader<'b, 'r>

§

impl<'b, 'r> UnsafeUnpin for ListReader<'b, 'r>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.