# Trait ethcore_util::standard::io::prelude::Seek 1.0.0 [−] [src]

    pub trait Seek {
        fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>;
    }

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, Error>`

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

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

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`.

# Errors

Seeking to a negative offset is considered an error.

## Implementors

- `impl Seek for File`
- `impl<'a> Seek for &'a File`
- `impl<R> Seek for BufReader<R> where R: Seek`
- `impl<W> Seek for BufWriter<W> where W: Write + Seek`
- `impl<T> Seek for Cursor<T> where T: AsRef<[u8]>`
- `impl<'a, S> Seek for &'a mut S where S: Seek + ?Sized`
- `impl<S> Seek for Box<S> where S: Seek + ?Sized`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)