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.