pub trait Input: Send + Sync {
// Required method
fn read(&mut self, buffer: &mut [u8]) -> Result<usize, InputError>;
// Provided methods
fn read_to_end(&mut self, out: &mut Vec<u8>) -> Result<(), InputError> { ... }
fn read_line(&mut self, line: &mut String) -> Result<bool, InputError> { ... }
}Expand description
A readable byte stream.
The Engine only knows about bytes; line orientation (if any) is a property of the stream’s source.
Required Methods§
Provided Methods§
Sourcefn read_to_end(&mut self, out: &mut Vec<u8>) -> Result<(), InputError>
fn read_to_end(&mut self, out: &mut Vec<u8>) -> Result<(), InputError>
Reads until end of stream, appending everything to out.
Sourcefn read_line(&mut self, line: &mut String) -> Result<bool, InputError>
fn read_line(&mut self, line: &mut String) -> Result<bool, InputError>
Reads a line (terminated by \n), appending it to line.
The trailing newline is included. Returns Ok(false) when the stream
is exhausted before any byte was read. Bytes are buffered to the
newline and decoded once, so multi-byte UTF-8 sequences survive;
bytes that are not valid UTF-8 are replaced with the Unicode
replacement character.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".