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

A read-only, forward-only* cursor into the data in an Input.

Using Reader to parse input helps to ensure that no byte of the input will be accidentally processed more than once. Using Reader in conjunction with read_all and read_all_optional helps ensure that no byte of the input is accidentally left unprocessed. The methods of Reader never panic, so Reader also assists the writing of panic-free code.

* Reader is not strictly forward-only because of the method get_input_between_marks, which is provided mainly to support calculating digests over parsed data.

Implementations

Construct a new Reader for the given input. Use read_all or read_all_optional instead of Reader::new whenever possible.

Returns true if the reader is at the end of the input, and false otherwise.

Returns an Input for already-parsed input that has had its boundaries marked using mark.

Return the current position of the Reader for future use in a call to get_input_between_marks.

Returns true if there is at least one more byte in the input and that byte is equal to b, and false otherwise.

Reads the next input byte.

Returns Ok(b) where b is the next input byte, or Err(EndOfInput) if the Reader is at the end of the input.

Skips num_bytes of the input, returning the skipped input as an Input.

Returns Ok(i) if there are at least num_bytes of input remaining, and Err(EndOfInput) otherwise.

Skips the reader to the end of the input, returning the skipped input as an Input.

Calls read() with the given input as a Reader. On success, returns a pair (bytes_read, r) where bytes_read is what read() consumed and r is read()’s return value.

Skips num_bytes of the input.

Returns Ok(i) if there are at least num_bytes of input remaining, and Err(EndOfInput) otherwise.

Skips the reader to the end of the input.

Trait Implementations

Formats the value using the given formatter. 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 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.