Struct Array

Source
pub struct Array<'a, L, T>
where T: DecoderFor<'a, T>,
{ /* private fields */ }
Expand description

A count-prefixed array.

Implementations§

Source§

impl<'a, T, L> Array<'a, L, T>
where T: DecoderFor<'a, T>,

Source

pub const fn new(buf: &'a [u8], len: usize) -> Array<'a, L, T>

Source

pub const fn empty() -> Array<'a, L, T>

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub const fn into_slice(self) -> &'a [u8]

Source§

impl<'a, T, L> Array<'a, L, T>
where T: DataTypeFixedSize + DecoderFor<'a, T>,

Source

pub fn get(&self, index: impl TryInto<usize>) -> Option<T>

Trait Implementations§

Source§

impl<'a, T, L> ArrayExt<'a> for Array<'a, L, T>
where T: DecoderFor<'a, T>, L: 'a,

Source§

fn into_slice(self) -> &'a [u8]

Convert the array into a slice of bytes.
Source§

impl<'a, T, L> AsRef<[u8]> for Array<'a, L, T>
where T: DecoderFor<'a, T>,

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, L, T> Clone for Array<'a, L, T>
where L: Clone, T: Clone + DecoderFor<'a, T>,

Source§

fn clone(&self) -> Array<'a, L, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, L, T> DataType for Array<'a, L, T>
where L: DataType, T: DataType + DecoderFor<'a, T>,

Source§

impl<'a, T, L> Debug for Array<'a, L, T>
where T: DecoderFor<'a, T> + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, L, T> DecoderFor<'a, Array<'a, L, T>> for Array<'a, L, T>
where L: DataType + 'a, T: DataType + DecoderFor<'a, T>,

Source§

fn decode_for(buf: &mut &'a [u8]) -> Result<Array<'a, L, T>, ParseError>

Source§

impl<'a, L, T> Default for Array<'a, L, T>
where L: Default, T: Default + DecoderFor<'a, T>,

Source§

fn default() -> Array<'a, L, T>

Returns the “default value” for a type. Read more
Source§

impl<T, L, IT> EncoderFor<Array<'static, L, T>> for &[IT]
where T: DataType + DecoderFor<'static, T>, L: DataType + 'static, IT: EncoderFor<T>,

Slice encoder

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<T, L, const N: usize, IT> EncoderFor<Array<'static, L, T>> for &[IT; N]
where T: DataType + DecoderFor<'static, T>, L: DataType + 'static, IT: EncoderFor<T>,

Array reference encoder

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<T, L, IT> EncoderFor<Array<'static, L, T>> for &Vec<IT>
where T: DataType + DecoderFor<'static, T>, L: DataType + 'static, IT: EncoderFor<T>,

Direct &Vec encoder

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<T, L, const N: usize, IT> EncoderFor<Array<'static, L, T>> for [IT; N]
where T: DataType + DecoderFor<'static, T>, L: DataType + 'static, IT: EncoderFor<T>,

Array encoder

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<T, L> EncoderFor<Array<'static, L, T>> for Array<'static, L, T>
where T: DataType + EncoderFor<T> + DecoderFor<'static, T>, L: DataType + 'static,

Self encoder

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<T, L, F, I, II, IT> EncoderFor<Array<'static, L, T>> for F
where T: DataType + DecoderFor<'static, T>, L: DataType + 'static, F: Fn() -> I, I: IntoIterator<Item = IT, IntoIter = II>, IT: EncoderFor<T>, II: ExactSizeIterator<Item = IT>,

Function encoder: see the note about about non-restartable iterators.

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<T, L, IT> EncoderFor<Array<'static, L, T>> for Vec<IT>
where T: DataType + DecoderFor<'static, T>, L: DataType + 'static, IT: EncoderFor<T>,

Direct Vec encoder

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

impl<'a, L> Index<usize> for Array<'a, L, u8>

Arrays of u8 can be indexed.

Source§

type Output = u8

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &<Array<'a, L, u8> as Index<usize>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T, L> IntoIterator for &Array<'a, L, T>
where T: DecoderFor<'a, T>,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = ArrayIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&Array<'a, L, T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, L> IntoIterator for Array<'a, L, T>
where T: DecoderFor<'a, T>,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = ArrayIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <Array<'a, L, T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, L> PartialEq<&[u8]> for Array<'a, L, u8>

Arrays of u8 can be compared to slices.

Source§

fn eq(&self, other: &&[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, L, const N: usize> PartialEq<&[u8; N]> for Array<'a, L, u8>

Arrays of u8 can be compared to fixed-size slices.

Source§

fn eq(&self, other: &&[u8; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, L, T> Copy for Array<'a, L, T>
where L: Copy, T: Copy + DecoderFor<'a, T>,

Auto Trait Implementations§

§

impl<'a, L, T> Freeze for Array<'a, L, T>

§

impl<'a, L, T> RefUnwindSafe for Array<'a, L, T>

§

impl<'a, L, T> Send for Array<'a, L, T>
where T: Send, L: Send,

§

impl<'a, L, T> Sync for Array<'a, L, T>
where T: Sync, L: Sync,

§

impl<'a, L, T> Unpin for Array<'a, L, T>
where T: Unpin, L: Unpin,

§

impl<'a, L, T> UnwindSafe for Array<'a, L, T>
where T: UnwindSafe, L: UnwindSafe,

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> EncoderFor<Rest<'static>> for T
where T: AsRef<[u8]>,

Source§

fn encode_for(&self, buf: &mut BufWriter<'_>)

Source§

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

Source§

fn to_vec<F>(&self) -> Vec<u8>
where F: 'static, Self: EncoderFor<F>,

Convert this builder into a vector of bytes. This is generally not the most efficient way to perform serialization.
Source§

fn encode_buffer<F>(&self, buf: &mut [u8]) -> Result<usize, usize>
where F: 'static, Self: EncoderFor<F>,

Encode this builder into a given buffer. If the buffer is too small, the function will return the number of bytes required to encode the builder.
Source§

fn encode_buffer_uninit<'a, F>( &self, buf: &'a mut [MaybeUninit<u8>], ) -> Result<&'a mut [u8], usize>
where F: 'static, Self: EncoderFor<F>,

Encode this builder into a given buffer. If the buffer is too small, the function will return the number of bytes required to encode the builder.
Source§

fn measure<F>(&self) -> usize
where F: 'static, Self: EncoderFor<F>,

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.