Struct wire_rs::VectoredCursor

source ·
pub struct VectoredCursor<'a> { /* private fields */ }
Expand description

A cursor that acts as an index over a set of vectored immutable slices and provides operations to sequentially read data from the slices.

When implementing the VectoredRead trait or one of its variants, this cursor provides an interface for reading data from the vectored wire. When an error is returned by the cursor, it should be returned by the trait method being implemented. This can be easily accomplished using the ? operator.

NOTE: this is an internal structure, and is NOT meant to be used to read data from a wire in the same manner as a WireReader. A WireReader is guaranteed to maintain the index of its last succesful read if any of its methods return an error, while this cursor may move its internal index forward by some unspecified amount when an error is encountered.

Implementations§

Advance the cursor’s index by the given amount, returning an error if there are insufficient bytes on the vectored wire.

Advance the cursor’s index by the given amount, or to the end of the vectored wire if the amount exceeds the number of remaining bytes.

Check whether the vectored wire has any remaining bytes that can be read by the cursor.

Retrieve a the next available byte from the wire.

Deserialize a given type T that implements the VectoredRead trait from the vectored wire, and return an owned instance of it.

The generic boolean E designates the intended endianness of the data being read. If E is set to true, then the data will be deserialized in big endian format; if false, it will be deserialized in little endian.

Deserialize L bytes from the vectored wire into a given type T that implements the VectoredReadPart trait, and return an owned instance of it.

The generic boolean E designates the intended endianness of the data being read. If E is set to true, then the data will be deserialized in big endian format; if false, it will be deserialized in little endian.

Deserialize a given type T that implements the VectoredReadRef trait from the vectored wire, and return a reference to it.

The generic boolean E designates the intended endianness of the data being read. If E is set to true, then the data will be deserialized in big endian format; if false, it will be deserialized in little endian.

Deserialize a given type T that implements the VectoredReadComp trait from the wire, and return an owned instance of it.

The generic boolean E designates the intended endianness of the data being read. If E is set to true, then the data will be deserialized in big endian format; if false, it will be deserialized in little endian.

Get the number of bytes remaining on the vectored wire for the given cursor.

Attempt to retrieve a contiguous slice of bytes from the wire, returning None if the next amount bytes are not all located on the same slice.

Attempt to retrieve a reference to a contiguous array of bytes of size L from the wire, returning None if the next L bytes are not all located on the same slice.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.