Trait async_std::io::Seek[][src]

pub trait Seek {
    fn poll_seek(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        pos: SeekFrom
    ) -> Poll<Result<u64>>; fn seek(&mut self, pos: SeekFrom) -> ImplFuture<Result<u64>>
    where
        Self: Unpin
, { ... } }
Expand description

Allows seeking through a byte stream.

This trait is a re-export of futures::io::AsyncSeek and is an async version of std::io::Seek.

The provided methods do not really exist in the trait itself, but they become available when SeekExt the prelude is imported:

use async_std::prelude::*;

Required methods

Attempt to seek to an offset, in bytes, in a stream.

Provided methods

Seeks to a new position in a byte stream.

Returns the new position in the byte stream.

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

Examples

use async_std::fs::File;
use async_std::io::SeekFrom;
use async_std::prelude::*;

let mut file = File::open("a.txt").await?;

let file_len = file.seek(SeekFrom::End(0)).await?;

Implementations on Foreign Types

Implementors