Trait opendal::raw::oio::RangeWrite

source ·
pub trait RangeWrite: Send + Sync + Unpin + 'static {
    // Required methods
    fn write_once(
        &self,
        size: u64,
        body: Buffer
    ) -> impl Future<Output = Result<()>> + MaybeSend;
    fn initiate_range(&self) -> impl Future<Output = Result<String>> + MaybeSend;
    fn write_range(
        &self,
        location: &str,
        offset: u64,
        size: u64,
        body: Buffer
    ) -> impl Future<Output = Result<()>> + MaybeSend;
    fn complete_range(
        &self,
        location: &str,
        offset: u64,
        size: u64,
        body: Buffer
    ) -> impl Future<Output = Result<()>> + MaybeSend;
    fn abort_range(
        &self,
        location: &str
    ) -> impl Future<Output = Result<()>> + MaybeSend;
}
Expand description

RangeWrite is used to implement [Write] based on range write.

§Services

Services like gcs support range write via GCS Resumable Upload.

GCS will support upload content by specifying the range of the file in CONTENT-RANGE.

Most range based services will have the following limitations:

  • The size of chunk per upload must be aligned to a certain size. For example, GCS requires to align with 256KiB.
  • Some services requires to complete the write at the last chunk with the total size.

§Architecture

The architecture after adopting RangeWrite:

  • Services impl RangeWrite
  • RangeWriter impl Write
  • Expose RangeWriter as Accessor::Writer

§Requirements

Services that implement RangeWrite must fulfill the following requirements:

  • Must be a http service that could accept AsyncBody.
  • Need initialization before writing.
  • Writing data based on range: offset, size.

Required Methods§

source

fn write_once( &self, size: u64, body: Buffer ) -> impl Future<Output = Result<()>> + MaybeSend

write_once is used to write the data to underlying storage at once.

RangeWriter will call this API when:

  • All the data has been written to the buffer and we can perform the upload at once.
source

fn initiate_range(&self) -> impl Future<Output = Result<String>> + MaybeSend

Initiate range the range write, the returning value is the location.

source

fn write_range( &self, location: &str, offset: u64, size: u64, body: Buffer ) -> impl Future<Output = Result<()>> + MaybeSend

write_range will write a range of data.

source

fn complete_range( &self, location: &str, offset: u64, size: u64, body: Buffer ) -> impl Future<Output = Result<()>> + MaybeSend

complete_range will complete the range write by uploading the last chunk.

source

fn abort_range( &self, location: &str ) -> impl Future<Output = Result<()>> + MaybeSend

abort_range will abort the range write by abort all already uploaded data.

Object Safety§

This trait is not object safe.

Implementors§