Struct wire_rs::WireReader

source ·
pub struct WireReader<'a, const E: bool = true> { /* private fields */ }
Expand description

A wrapper around a &[u8] slice that provides an easy interface for reading data types from the slice.

Implementations§

Create a WireReader that can read data types sequentially from the bytes slice.

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. If unset, this will default to true, or big endian.

Advance the reader’s index forward by the given amount of bytes, returning an error if there are insufficient bytes on the wire to do so.

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

Check if the reader has no more bytes left on the wire that can be read. If any bytes remain, return WireError::ExtraBytes; otherwise, return Ok().

Check if the reader has no more bytes left on the wire that can be read after the given action. If any bytes remain, return WireError::ExtraBytes; otherwise, return Ok().

Check whether the reader has any remaining bytes to be read.

Read the given data type T from the wire without advancing the index of the reader.

Read the given data type T from the wire without advancing the index of the reader.

Read the given data type T from L bytes on the wire without advancing the index of the reader.

Read the given data type T from size bytes on the wire without advancing the index of the reader.

Read the given data type T from the wire.

Read the given data type T from the wire.

Read the given data type T from size bytes on the wire.

Read the given data type T from the wire.

Read the given data type T from the remaining data on the wire. Note that this operation may succeed even if there are no bytes remaining on the wire for the given reader.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
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 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.