Trait Stream

Source
pub trait Stream:
    Read
    + Write
    + Seek {
    // Required methods
    fn position(&self) -> Result<u64>;
    fn eof(&self) -> bool;
    fn errno(&self) -> i32;
    fn last_error(&self) -> Option<Error>;
    fn clear_error(&self);
    fn file_name(&self) -> Result<PathBuf>;
    fn metadata(&self) -> Result<Metadata>;
    fn read_slice<T: Sized>(&mut self, elements: &mut [T]) -> Result<usize>;
    fn write_slice<T: Sized>(&mut self, elements: &[T]) -> Result<usize>;
}
Expand description

The C *FILE stream

Required Methods§

Source

fn position(&self) -> Result<u64>

returns the current position of the stream.

Source

fn eof(&self) -> bool

tests the end-of-file indicator for the stream

Source

fn errno(&self) -> i32

tests the error indicator for the stream

Source

fn last_error(&self) -> Option<Error>

get the last error of the stream

Source

fn clear_error(&self)

clears the end-of-file and error indicators for the stream

Source

fn file_name(&self) -> Result<PathBuf>

returns the file name of the stream

Source

fn metadata(&self) -> Result<Metadata>

Queries metadata about the underlying file.

Source

fn read_slice<T: Sized>(&mut self, elements: &mut [T]) -> Result<usize>

Reads n elements of data, return the number of items read.

Source

fn write_slice<T: Sized>(&mut self, elements: &[T]) -> Result<usize>

Writes n elements of data, return the number of items written.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§