Trait opendal::raw::oio::BlockingWrite

source ·
pub trait BlockingWrite: Send + Sync + 'static {
    // Required methods
    fn write(&mut self, bs: Buffer) -> Result<usize>;
    fn close(&mut self) -> Result<()>;
}
Expand description

BlockingWrite is the trait that OpenDAL returns to callers.

Required Methods§

source

fn write(&mut self, bs: Buffer) -> Result<usize>

Write whole content at once.

§Behavior
  • Ok(n) means n bytes has been written successfully.
  • Err(err) means error happens and no bytes has been written.

It’s possible that n < bs.len(), caller should pass the remaining bytes repeatedly until all bytes has been written.

§Safety
  • The caller MUST ensure that the buffer is valid before write returns Ready.
  • The implementor SHOULD NOT store [oio::ReadableBuf] in anyways. The buf MUST be passed by or copied out to an owned buffer.
source

fn close(&mut self) -> Result<()>

Close the writer and make sure all data has been flushed.

Implementations on Foreign Types§

source§

impl BlockingWrite for ()

source§

fn write(&mut self, bs: Buffer) -> Result<usize>

source§

fn close(&mut self) -> Result<()>

source§

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

Box<dyn BlockingWrite> won’t implement BlockingWrite automatically.

To make BlockingWriter work as expected, we must add this impl.

source§

fn write(&mut self, bs: Buffer) -> Result<usize>

source§

fn close(&mut self) -> Result<()>

Implementors§