Trait sigma_ser::peekable_reader::Peekable[][src]

pub trait Peekable: Read {
    fn peek_u8(&mut self) -> Result<u8, &Error>;
}
Expand description

A wrapper around any struct implementing the Read trait, additionally allowing for peek operations to be performed. Therefore, the PeekableReader struct also implements the Read trait.

The primary invariant of the PeekableReader is that after calling the peek method, the next read_byte call will return the same result as the peek does. When the result is a byte (read off the wrapped reader), any read-type method of the Reader trait will include the byte as the first one. On the other hand, if the result is an io::Error, the error will be returned regardless of which read-type method of the Reader is invoked. Consecutive peeks before any read-type operation is used always return the same io::Result.

Required methods

fn peek_u8(&mut self) -> Result<u8, &Error>[src]

When using peek_u8 you will get a Result<u8, &Error>, while when you call any of the Read functions you will get an io::Result, thereby consuming the io::Error (if any.)

Implementors

impl<R: Read> Peekable for PeekableReader<R>[src]

fn peek_u8(&mut self) -> Result<u8, &Error>[src]

Returns the io::Result which the Reader will return on the next get_byte call.

If the io::Result is indeed an io::Error, the error will be returned for any subsequent read operation invoked upon the Reader.