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§
sourcefn poll_read(
&mut self,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
fn poll_read( &mut self, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<usize>>
Read bytes asynchronously.
sourcefn poll_seek(&mut self, cx: &mut Context<'_>, pos: SeekFrom) -> Poll<Result<u64>>
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.
sourcefn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>>
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
impl AsyncRead for dyn Read
source§impl Stream for dyn Read
impl Stream for dyn Read
Implementations on Foreign Types§
source§impl<T: Read + ?Sized> Read for Box<T>
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.