Trait opendal::raw::oio::RangeWrite
source · pub trait RangeWrite: Send + Sync + Unpin + 'static {
// Required methods
fn write_once(
&self,
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,
body: Buffer,
) -> impl Future<Output = Result<()>> + MaybeSend;
fn complete_range(
&self,
location: &str,
offset: 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 oio::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
implWrite
- Expose
RangeWriter
asAccessor::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§
sourcefn write_once(
&self,
body: Buffer,
) -> impl Future<Output = Result<()>> + MaybeSend
fn write_once( &self, 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.
sourcefn initiate_range(&self) -> impl Future<Output = Result<String>> + MaybeSend
fn initiate_range(&self) -> impl Future<Output = Result<String>> + MaybeSend
Initiate range the range write, the returning value is the location.
sourcefn write_range(
&self,
location: &str,
offset: u64,
body: Buffer,
) -> impl Future<Output = Result<()>> + MaybeSend
fn write_range( &self, location: &str, offset: u64, body: Buffer, ) -> impl Future<Output = Result<()>> + MaybeSend
write_range will write a range of data.
Object Safety§
This trait is not object safe.