[][src]Trait spectrusty_formats::ReadExactEx

pub trait ReadExactEx: Read {
    pub fn read_exact_or_to_end(&mut self, buf: &mut [u8]) -> Result<usize> { ... }
pub fn read_exact_or_none(&mut self, buf: &mut [u8]) -> Result<bool> { ... } }

A trait that extends Read with methods that ease reading from chunked files.

Provided methods

pub fn read_exact_or_to_end(&mut self, buf: &mut [u8]) -> Result<usize>

Reads all bytes to fill buf or until EOF. If successful, returns the total number of bytes read.

This function behaves like Read::read_to_end but it reads data into the mutable slice instead of into a Vec and stops reading when the whole buf has been filled.

pub fn read_exact_or_none(&mut self, buf: &mut [u8]) -> Result<bool>

Reads the exact number of bytes required to fill buf and returns Ok(true) or returns Ok(false) if exactly zero bytes were read. In this instance, buf will be left unmodified.

If at least one byte was read, this function behaves exactly like Read::read_exact.

Loading content...

Implementors

impl<R: Read> ReadExactEx for R[src]

Loading content...