Struct wire_rs::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§

Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.