This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch try-into-future
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 23a4b5b0ead7663a161460b5acdc7e4e1a57e815
Author: Xuanwo <[email protected]>
AuthorDate: Tue Jan 30 16:40:22 2024 +0800

    Fix build
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/types/operator/operator.rs         |  9 ++---
 core/src/types/operator/operator_futures.rs | 55 +++++++++++++++++++++++++++--
 2 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/core/src/types/operator/operator.rs 
b/core/src/types/operator/operator.rs
index ea572a9729..8c50d7db4c 100644
--- a/core/src/types/operator/operator.rs
+++ b/core/src/types/operator/operator.rs
@@ -693,7 +693,7 @@ impl Operator {
     /// # Ok(())
     /// # }
     /// ```
-    pub fn writer_with(&self, path: &str) -> FutureWrite<impl Future<Output = 
Result<Writer>>> {
+    pub fn writer_with(&self, path: &str) -> FutureWriter<impl Future<Output = 
Result<Writer>>> {
         let path = normalize_path(path);
 
         OperatorFuture::new(
@@ -744,13 +744,13 @@ impl Operator {
         bs: impl Into<Bytes>,
     ) -> FutureWrite<impl Future<Output = Result<()>>> {
         let path = normalize_path(path);
-        let mut bs = bs.into();
+        let bs = bs.into();
 
         OperatorFuture::new(
             self.inner().clone(),
             path,
-            OpWrite::default(),
-            |inner, path, args| async move {
+            (OpWrite::default(), bs),
+            |inner, path, (args, mut bs)| async move {
                 if !validate_path(&path, EntryMode::FILE) {
                     return Err(
                         Error::new(ErrorKind::IsADirectory, "write path is a 
directory")
@@ -767,6 +767,7 @@ impl Operator {
                 }
 
                 w.close().await?;
+
                 Ok(())
             },
         )
diff --git a/core/src/types/operator/operator_futures.rs 
b/core/src/types/operator/operator_futures.rs
index 1213104e4f..e05aa01dc2 100644
--- a/core/src/types/operator/operator_futures.rs
+++ b/core/src/types/operator/operator_futures.rs
@@ -23,6 +23,7 @@ use std::future::IntoFuture;
 use std::ops::RangeBounds;
 use std::time::Duration;
 
+use bytes::Bytes;
 use flagset::FlagSet;
 use futures::Future;
 
@@ -248,12 +249,62 @@ impl<F> FutureRead<F> {
     }
 }
 
-/// Future that generated by [`Operator::write_with`] or 
[`Operator::writer_with`].
+/// Future that generated by [`Operator::write_with`].
 ///
 /// Users can add more options by public functions provided by this struct.
-pub type FutureWrite<F> = OperatorFuture<OpWrite, F>;
+pub type FutureWrite<F> = OperatorFuture<(OpWrite, Bytes), F>;
 
 impl<F> FutureWrite<F> {
+    /// Set the append mode of op.
+    ///
+    /// If the append mode is set, the data will be appended to the end of the 
file.
+    ///
+    /// # Notes
+    ///
+    /// Service could return `Unsupported` if the underlying storage does not 
support append.
+    pub fn append(self, v: bool) -> Self {
+        self.map(|(args, bs)| (args.with_append(v), bs))
+    }
+
+    /// Set the buffer size of op.
+    ///
+    /// If buffer size is set, the data will be buffered by the underlying 
writer.
+    ///
+    /// ## NOTE
+    ///
+    /// Service could have their own minimum buffer size while perform write 
operations like
+    /// multipart uploads. So the buffer size may be larger than the given 
buffer size.
+    pub fn buffer(self, v: usize) -> Self {
+        self.map(|(args, bs)| (args.with_buffer(v), bs))
+    }
+
+    /// Set the content type of option
+    pub fn content_type(self, v: &str) -> Self {
+        self.map(|(args, bs)| (args.with_content_type(v), bs))
+    }
+
+    /// Set the content disposition of option
+    pub fn content_disposition(self, v: &str) -> Self {
+        self.map(|(args, bs)| (args.with_content_disposition(v), bs))
+    }
+
+    /// Set the content type of option
+    pub fn cache_control(self, v: &str) -> Self {
+        self.map(|(args, bs)| (args.with_cache_control(v), bs))
+    }
+
+    /// Set the maximum concurrent write task amount.
+    pub fn concurrent(self, v: usize) -> Self {
+        self.map(|(args, bs)| (args.with_buffer(v), bs))
+    }
+}
+
+/// Future that generated by [`Operator::writer_with`].
+///
+/// Users can add more options by public functions provided by this struct.
+pub type FutureWriter<F> = OperatorFuture<OpWrite, F>;
+
+impl<F> FutureWriter<F> {
     /// Set the append mode of op.
     ///
     /// If the append mode is set, the data will be appended to the end of the 
file.

Reply via email to