Trait opendal::raw::oio::Read

source ·
pub trait Read: Unpin + Send + Sync {
    // Required methods
    fn poll_read(
        &mut self,
        cx: &mut Context<'_>,
        buf: &mut [u8]
    ) -> Poll<Result<usize>>;
    fn poll_seek(
        &mut self,
        cx: &mut Context<'_>,
        pos: SeekFrom
    ) -> Poll<Result<u64>>;
    fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>>;
}
Expand description

Read is the trait that OpenDAL returns to callers.

Read is compose of the following trait

  • AsyncRead
  • AsyncSeek
  • Stream<Item = Result<Bytes>>

AsyncRead is required to be implemented, AsyncSeek and Stream is optional. We use Read to make users life easier.

Required Methods§

source

fn poll_read( &mut self, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<usize>>

Read bytes asynchronously.

source

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

Seek asynchronously.

Returns Unsupported error if underlying reader doesn’t support seek.

source

fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>>

Stream Bytes from underlying reader.

Returns Unsupported error if underlying reader doesn’t support stream.

This API exists for avoiding bytes copying inside async runtime. Users can poll bytes from underlying reader and decide when to read/consume them.

Trait Implementations§

source§

impl AsyncRead for dyn Read

source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<usize>>

Attempt to read from the AsyncRead into buf. Read more
§

fn poll_read_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>] ) -> Poll<Result<usize, Error>>

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
source§

impl AsyncSeek for dyn Read

source§

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

Attempt to seek to an offset, in bytes, in a stream. Read more
source§

impl Stream for dyn Read

§

type Item = Result<Bytes, Error>

Values yielded by the stream.
source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more

Implementations on Foreign Types§

source§

impl Read for ()

source§

fn poll_read( &mut self, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<usize>>

source§

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

source§

fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>>

source§

impl<T: Read + ?Sized> Read for Box<T>

Box<dyn Read> won’t implement Read automatically. To make Reader work as expected, we must add this impl.

source§

fn poll_read( &mut self, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<usize>>

source§

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

source§

fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>>

Implementors§

source§

impl Read for Reader

source§

impl Read for IncomingAsyncBody

source§

impl Read for Cursor

source§

impl<A: Accessor> Read for RangeReader<A>

source§

impl<R> Read for FdReader<R>where R: AsyncRead + AsyncSeek + Unpin + Send + Sync,

source§

impl<R: Read> Read for IntoStreamableReader<R>