Skip to content

AsyncSeek #9

@nrc

Description

@nrc

An async version of the Seek trait:

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

    fn rewind(&mut self) -> Result<()> { ... }
    fn stream_len(&mut self) -> Result<u64> { ... }
    fn stream_position(&mut self) -> Result<u64> { ... }
}

Prior art

futures-rs

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

Tokio

pub trait AsyncSeek {
    fn start_seek(self: Pin<&mut Self>, position: SeekFrom) -> Result<()>;

    fn poll_complete(
        self: Pin<&mut Self>, 
        cx: &mut Context<'_>
    ) -> Poll<Result<u64>>;
}

async-std

Extends futures-rs with a convenience seek function

    fn seek(&mut self, pos: SeekFrom) -> ImplFuture<Result<u64>>
    where
        Self: Unpin,
    { ... }

Misc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-stdlibArea: a standard library for async Rust

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions