Trait opendal::raw::oio::Read

source ·
pub trait Read: Unpin + Send + Sync {
    // Required method
    fn read_at(
        &self,
        offset: u64,
        limit: usize
    ) -> impl Future<Output = Result<Buffer>> + MaybeSend;
}
Expand description

Read is the internal trait used by OpenDAL to read data from storage.

Users should not use or import this trait unless they are implementing an Accessor.

§Notes

§Object Safety

Read uses async in trait, making it not object safe, preventing the use of Box<dyn Read>. To address this, we’ve introduced ReadDyn and its compatible type Box<dyn ReadDyn>.

ReadDyn uses Box::pin() to transform the returned future into a BoxedFuture, introducing an additional layer of indirection and an extra allocation. Ideally, ReadDyn should occur only once, at the outermost level of our API.

Required Methods§

source

fn read_at( &self, offset: u64, limit: usize ) -> impl Future<Output = Result<Buffer>> + MaybeSend

Read at the given offset with the given limit.

§Notes

Storage services should try to read as much as possible, only return bytes less than the limit while reaching the end of the file.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Read for ()

source§

async fn read_at(&self, offset: u64, limit: usize) -> Result<Buffer>

source§

impl Read for Bytes

source§

async fn read_at(&self, offset: u64, limit: usize) -> Result<Buffer>

source§

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

§NOTE

Take care about the deref_mut() here. This makes sure that we are calling functions upon &mut T instead of &mut Box<T>. The later could result in infinite recursion.

source§

async fn read_at(&self, offset: u64, limit: usize) -> Result<Buffer>

source§

impl<T: ReadDyn + ?Sized> Read for Arc<T>

source§

async fn read_at(&self, offset: u64, limit: usize) -> Result<Buffer>

Implementors§

source§

impl Read for Buffer

source§

impl<ONE, TWO, THREE, FOUR> Read for FourWays<ONE, TWO, THREE, FOUR>
where ONE: Read, TWO: Read, THREE: Read, FOUR: Read,

source§

impl<ONE: Read, TWO: Read> Read for TwoWays<ONE, TWO>

source§

impl<ONE: Read, TWO: Read, THREE: Read> Read for ThreeWays<ONE, TWO, THREE>