futures::prelude

Trait AsyncSeek

Source
pub trait AsyncSeek {
    // Required method
    fn poll_seek(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        pos: SeekFrom,
    ) -> Poll<Result<u64, Error>>;
}
Expand description

Seek bytes asynchronously.

This trait is analogous to the std::io::Seek trait, but integrates with the asynchronous task system. In particular, the poll_seek method, unlike Seek::seek, will automatically queue the current task for wakeup and return if data is not yet available, rather than blocking the calling thread.

Required Methods§

Source

fn poll_seek( self: Pin<&mut Self>, cx: &mut Context<'_>, pos: SeekFrom, ) -> Poll<Result<u64, Error>>

Attempt to 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.

§Errors

Seeking to a negative offset is considered an error.

§Implementation

This function may not return errors of kind WouldBlock or Interrupted. Implementations must convert WouldBlock into Poll::Pending and either internally retry or convert Interrupted into another error kind.

Implementations on Foreign Types§

Source§

impl<P> AsyncSeek for Pin<P>
where P: DerefMut + Unpin, <P as Deref>::Target: AsyncSeek,

Source§

fn poll_seek( self: Pin<&mut Pin<P>>, cx: &mut Context<'_>, pos: SeekFrom, ) -> Poll<Result<u64, Error>>

Source§

impl<T> AsyncSeek for &mut T
where T: AsyncSeek + Unpin + ?Sized,

Source§

fn poll_seek( self: Pin<&mut &mut T>, cx: &mut Context<'_>, pos: SeekFrom, ) -> Poll<Result<u64, Error>>

Source§

impl<T> AsyncSeek for Box<T>
where T: AsyncSeek + Unpin + ?Sized,

Source§

fn poll_seek( self: Pin<&mut Box<T>>, cx: &mut Context<'_>, pos: SeekFrom, ) -> Poll<Result<u64, Error>>

Implementors§

Source§

impl<A, B> AsyncSeek for Either<A, B>
where A: AsyncSeek, B: AsyncSeek,

Source§

impl<R> AsyncSeek for BufReader<R>
where R: AsyncRead + AsyncSeek,

Source§

impl<T> AsyncSeek for AllowStdIo<T>
where T: Seek,

Source§

impl<T> AsyncSeek for Cursor<T>
where T: AsRef<[u8]> + Unpin,

Source§

impl<W> AsyncSeek for BufWriter<W>
where W: AsyncWrite + AsyncSeek,