Skip to main content

Stream

Trait Stream 

Source
pub trait Stream: Send {
    // Provided methods
    fn read(&mut self, _buf: &mut [u8]) -> Result<usize, IoError> { ... }
    fn write(&mut self, _data: &[u8]) -> Result<(), IoError> { ... }
    fn flush(&mut self) -> Result<(), IoError> { ... }
    fn seek(&mut self, _pos: SeekFrom) -> Result<u64, IoError> { ... }
    fn close(&mut self) -> Result<(), IoError> { ... }
}
Expand description

A stream a script’s io reads and writes. Each method defaults to C’s failure on a stream that cannot do it. Calls run inside the script’s call: a stream that blocks holds the script (fuel and the deadline are not read meanwhile).

Provided Methods§

Source

fn read(&mut self, _buf: &mut [u8]) -> Result<usize, IoError>

Reads into buf; 0 is the end.

Source

fn write(&mut self, _data: &[u8]) -> Result<(), IoError>

Writes all of data.

Source

fn flush(&mut self) -> Result<(), IoError>

Flushes what was written.

Source

fn seek(&mut self, _pos: SeekFrom) -> Result<u64, IoError>

Moves to pos; the new position from the start.

Source

fn close(&mut self) -> Result<(), IoError>

Closes the stream (file:close()); it is dropped after.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§