Struct WireIndex

Source
pub struct WireIndex {
    pub vectored_idx: usize,
    pub slice_idx: usize,
}
Expand description

An index of a buffer or vectored buffers.

This type is created from a Wire or Vectored Reader/Writer type. Its primary use is to provide a mechanism for advancing a slice or vectored slice up by the amount consumed by the Reader/Writer without causing any lifetime issues.

Readers and Writers carry a reference to the buffer they are reading, which means that no mutations can be performed on the referenced buffer while a Reader is in scope. Converting a reader into a WireIndex provides a mechanism to drop the Reader while retaining the index that the Reader had reached. Once the buffer has been mutated (e.g. additional data being written into it), a slice of the new contents (starting at the index stored in the WireIndex) can be used to create a new Reader. That reader can then continue to extract data from the buffer.

Fields§

§vectored_idx: usize

The index of which buffer in the set of vectored buffers the reader or writer was at.

If the given WireIndex was created from a WireReader or WireWriter and not a VectoredReader or VectoredWriter, this value will always be set to 0.

§slice_idx: usize

The index within the buffer that the reader or writer was at.

Trait Implementations§

Source§

impl From<VectoredReader<'_>> for WireIndex

Source§

fn from(reader: VectoredReader<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<VectoredWriter<'_>> for WireIndex

Source§

fn from(writer: VectoredWriter<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<WireReader<'_>> for WireIndex

Source§

fn from(reader: WireReader<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<WireWriter<'_>> for WireIndex

Source§

fn from(writer: WireWriter<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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, 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.