Trait opendal::raw::oio::Read

source ·
pub trait Read: Unpin + Send + Sync {
    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§

Read bytes asynchronously.

Seek asynchronously.

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

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§

Attempt to read from the AsyncRead into buf. Read more
Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
Attempt to seek to an offset, in bytes, in a stream. Read more
Values yielded by the stream.
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
Returns the bounds on the remaining length of the stream. Read more

Implementations on Foreign Types§

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

Implementors§