Trait std::io::Seek
[−]
[src]
pub trait Seek { fn seek(&mut self, pos: SeekFrom) -> Result<u64>; }
The Seek
trait provides a cursor which can be moved within a stream of
bytes.
The stream typically has a fixed size, allowing seeking relative to either end or the current offset.
Examples
File
s implement Seek
:
use std::io; use std::io::prelude::*; use std::fs::File; use std::io::SeekFrom; let mut f = try!(File::open("foo.txt")); // move the cursor 42 bytes from the start of the file try!(f.seek(SeekFrom::Start(42)));
Required Methods
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 implementation defined.
The behavior when seeking past the end of the stream is implementation defined.
This method returns the new position within the stream if the seek operation completed successfully.
Errors
Seeking to a negative offset is considered an error.