Struct wire_rs::WireCursor

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

A cursor that acts as an index over a contiguous immutable slice and provides operations to sequentially read data from it.

When implementing the WireRead trait or one of its variants, this cursor provides an interface for reading data from the 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 wire.

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

Retrieve a reference to an array of bytes of size L from the wire.

Deserialize a given type T that implements the WireRead 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.

Deserialize L bytes from the wire into a given type T that implements the WireReadPart 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 WireReadRef trait from the 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 WireReadComp 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.

Retrieve a slice of bytes from the wire.

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

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

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.