pub struct Reader<'a> { /* private fields */ }
Expand description

Wrapper over a slice of bytes that allows reading chunks from with the current position state held using a cursor.

A new reader for a sub section of the the buffer can be created using the sub function or a section of a certain length can be obtained using the take function

Implementations

Creates a new Reader of the provided bytes slice with the initial cursor position of zero.

Attempts to create a new Reader on a sub section of this readers bytes by taking a slice of the provided length will return None if there is not enough bytes

Borrows a slice of all the remaining bytes that appear after the cursor position.

Moves the cursor to the end of the buffer length.

Attempts to borrow a slice of bytes from the current cursor position of length if there is not enough bytes remaining after the cursor to take the length then None is returned instead.

Used to check whether the reader has any content left after the cursor (cursor has not reached end of buffer)

Returns the cursor position which is also the number of bytes that have been read from the buffer.

Returns the number of bytes that are still able to be read (The number of remaining takes)

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.