Skip to main content

Seek

Trait Seek 

Source
pub trait Seek {
    // Required method
    fn seek(&mut self, pos: SeekFrom) -> Result<u64, AxError>;

    // Provided methods
    fn rewind(&mut self) -> Result<(), AxError> { ... }
    fn stream_position(&mut self) -> Result<u64, AxError> { ... }
    fn stream_len(&mut self) -> Result<u64, AxError> { ... }
    fn seek_relative(&mut self, offset: i64) -> Result<(), AxError> { ... }
}
Expand description

The Seek trait provides a cursor which can be moved within a stream of bytes.

See [std::io::Seek] for more details.

Required Methods§

Source

fn seek(&mut self, pos: SeekFrom) -> Result<u64, AxError>

Seek to an offset, in bytes, in a stream.

A seek beyond the end of a stream is allowed, but behavior is defined by the implementation.

If the seek operation completed successfully, this method returns the new position from the start of the stream. That position can be used later with SeekFrom::Start.

Provided Methods§

Source

fn rewind(&mut self) -> Result<(), AxError>

Rewind to the beginning of a stream.

This is a convenience method, equivalent to seek(SeekFrom::Start(0)).

Source

fn stream_position(&mut self) -> Result<u64, AxError>

Returns the current seek position from the start of the stream.

This is equivalent to self.seek(SeekFrom::Current(0)).

Source

fn stream_len(&mut self) -> Result<u64, AxError>

Returns the length of this stream (in bytes).

Source

fn seek_relative(&mut self, offset: i64) -> Result<(), AxError>

Seeks relative to the current position.

Implementations on Foreign Types§

Source§

impl<S> Seek for &mut S
where S: Seek + ?Sized,

Source§

fn seek(&mut self, pos: SeekFrom) -> Result<u64, AxError>

Source§

fn rewind(&mut self) -> Result<(), AxError>

Source§

fn stream_len(&mut self) -> Result<u64, AxError>

Source§

fn stream_position(&mut self) -> Result<u64, AxError>

Source§

fn seek_relative(&mut self, offset: i64) -> Result<(), AxError>

Implementors§

Source§

impl Seek for Empty

Source§

impl<R> Seek for BufReader<R>
where R: Seek + ?Sized,

Source§

impl<T> Seek for Cursor<T>
where T: AsRef<[u8]>,

Source§

impl<T> Seek for Take<T>
where T: Seek,

Source§

impl<W> Seek for BufWriter<W>
where W: Write + Seek + ?Sized,