Trait VecSource

Source
pub trait VecSource: DataSource {
    // Required method
    fn read_to_end<'a>(&mut self, buf: &'a mut Vec<u8>) -> Result<&'a [u8]>;
}
Expand description

A source stream reading data into vectors.

Required Methods§

Source

fn read_to_end<'a>(&mut self, buf: &'a mut Vec<u8>) -> Result<&'a [u8]>

Reads bytes into buf until the presumptive end of the stream, returning the bytes read. If an error is returned, any bytes read remain in buf.

Note that the stream may not necessarily have ended; more bytes may still be read in subsequent calls. The stream’s end is only presumed to be reached. For example, a TCP socket may read no data signaling an end, but later begin reading again.

§Errors

Returns any IO errors encountered.

§Example
use data_streams::VecSource;

let mut input: &[u8] = b"Hello!";
let mut buf = Vec::new();
assert_eq!(input.read_to_end(&mut buf)?, b"Hello!");

Implementations on Foreign Types§

Source§

impl VecSource for VecDeque<u8>

Source§

fn read_to_end<'a>(&mut self, buf: &'a mut Vec<u8>) -> Result<&'a [u8]>

Implementors§