pub trait Seek {
// Required method
fn seek(&mut self, pos: SeekFrom) -> Result<u64>;
// Provided methods
fn rewind(&mut self) -> Result<()> { ... }
fn stream_position(&mut self) -> Result<u64> { ... }
}
Expand description
The Seek
trait provides a cursor which can be moved within a stream of
bytes.
Required Methods§
sourcefn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
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§
sourcefn rewind(&mut self) -> Result<()>
fn rewind(&mut self) -> Result<()>
Rewind to the beginning of a stream.
This is a convenience method, equivalent to seek(SeekFrom::Start(0))
.
sourcefn stream_position(&mut self) -> Result<u64>
fn stream_position(&mut self) -> Result<u64>
Returns the current seek position from the start of the stream.
This is equivalent to self.seek(SeekFrom::Current(0))
.