Type Alias FutureWrite

Source
pub type FutureWrite<F> = OperatorFuture<(WriteOptions, Buffer), Metadata, F>;
Expand description

Future that generated by Operator::write_with.

Users can add more options by public functions provided by this struct.

Aliased Type§

struct FutureWrite<F> { /* private fields */ }

Implementations§

Source§

impl<F: Future<Output = Result<Metadata>>> FutureWrite<F>

Source

pub fn append(self, v: bool) -> Self

Sets append mode for this write request.

Refer to options::WriteOptions::append for more details.

§Example
use bytes::Bytes;

let _ = op.write_with("path/to/file", vec![0; 4096]).append(true).await?;
Source

pub fn chunk(self, v: usize) -> Self

Sets chunk size for buffered writes.

Refer to options::WriteOptions::chunk for more details.

§Example
use bytes::Bytes;

// Set 8MiB chunk size - data will be sent in one API call at close
let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .chunk(8 * 1024 * 1024)
    .await?;
Source

pub fn concurrent(self, v: usize) -> Self

Sets concurrent write operations for this writer.

Refer to options::WriteOptions::concurrent for more details.

§Example
use bytes::Bytes;

// Enable concurrent writes with 8 parallel operations at 128B chunk.
let _ = op.write_with("path/to/file", vec![0; 4096]).chunk(128).concurrent(8).await?;
Source

pub fn cache_control(self, v: &str) -> Self

Sets Cache-Control header for this write operation.

Refer to options::WriteOptions::cache_control for more details.

§Example
use bytes::Bytes;

// Cache content for 7 days (604800 seconds)
let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .cache_control("max-age=604800")
    .await?;
Source

pub fn content_type(self, v: &str) -> Self

Sets Content-Type header for this write operation.

Refer to options::WriteOptions::content_type for more details.

§Example
use bytes::Bytes;

// Set content type for plain text file
let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .content_type("text/plain")
    .await?;
Source

pub fn content_disposition(self, v: &str) -> Self

Sets Content-Disposition header for this write request.

Refer to options::WriteOptions::content_disposition for more details.

§Example
use bytes::Bytes;

let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .content_disposition("attachment; filename=\"filename.jpg\"")
    .await?;
Source

pub fn content_encoding(self, v: &str) -> Self

Sets Content-Encoding header for this write request.

Refer to options::WriteOptions::content_encoding for more details.

§Example
use bytes::Bytes;

let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .content_encoding("gzip")
    .await?;
Source

pub fn if_match(self, s: &str) -> Self

Sets If-Match header for this write request.

Refer to options::WriteOptions::if_match for more details.

§Example
use bytes::Bytes;

let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .if_match("\"686897696a7c876b7e\"")
    .await?;
Source

pub fn if_none_match(self, s: &str) -> Self

Sets If-None-Match header for this write request.

Refer to options::WriteOptions::if_none_match for more details.

§Example
use bytes::Bytes;

let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .if_none_match("\"686897696a7c876b7e\"")
    .await?;
Source

pub fn if_not_exists(self, b: bool) -> Self

Sets the condition that write operation will succeed only if target does not exist.

Refer to options::WriteOptions::if_not_exists for more details.

§Example
use bytes::Bytes;

let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .if_not_exists(true)
    .await?;
Source

pub fn user_metadata( self, data: impl IntoIterator<Item = (String, String)>, ) -> Self

Sets user metadata for this write request.

Refer to options::WriteOptions::user_metadata for more details.

§Example
use bytes::Bytes;

let _ = op
    .write_with("path/to/file", vec![0; 4096])
    .user_metadata([
        ("language".to_string(), "rust".to_string()),
        ("author".to_string(), "OpenDAL".to_string()),
    ])
    .await?;