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

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


The following commit(s) were added to refs/heads/main by this push:
     new bae04af5 feat: add If-Match Support for OpRead, OpWrite, OpStat (#2017)
bae04af5 is described below

commit bae04af594b4ff0379d9b3d5c71f74d2e5857fad
Author: Zhou Zhiqiang <[email protected]>
AuthorDate: Mon Apr 17 16:48:18 2023 +0800

    feat: add If-Match Support for OpRead, OpWrite, OpStat (#2017)
    
    Signed-off-by: STRRL <[email protected]>
---
 core/src/types/ops.rs | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/core/src/types/ops.rs b/core/src/types/ops.rs
index 84089e44..3d24f45e 100644
--- a/core/src/types/ops.rs
+++ b/core/src/types/ops.rs
@@ -222,6 +222,7 @@ pub struct OpRead {
     br: BytesRange,
     override_content_disposition: Option<String>,
     override_cache_control: Option<String>,
+    if_match: Option<String>,
     if_none_match: Option<String>,
 }
 
@@ -265,6 +266,17 @@ impl OpRead {
         self.override_cache_control.as_deref()
     }
 
+    /// Set the If-Match of the option
+    pub fn with_if_match(mut self, if_match: &str) -> Self {
+        self.if_match = Some(if_match.to_string());
+        self
+    }
+
+    /// Get If-Match from option
+    pub fn if_match(&self) -> Option<&str> {
+        self.if_match.as_deref()
+    }
+
     /// Set the If-None-Match of the option
     pub fn with_if_none_match(mut self, if_none_match: &str) -> Self {
         self.if_none_match = Some(if_none_match.to_string());
@@ -280,6 +292,7 @@ impl OpRead {
 /// Args for `stat` operation.
 #[derive(Debug, Clone, Default)]
 pub struct OpStat {
+    if_match: Option<String>,
     if_none_match: Option<String>,
 }
 
@@ -289,6 +302,17 @@ impl OpStat {
         Self::default()
     }
 
+    /// Set the If-Match of the option
+    pub fn with_if_match(mut self, if_match: &str) -> Self {
+        self.if_match = Some(if_match.to_string());
+        self
+    }
+
+    /// Get If-Match from option
+    pub fn if_match(&self) -> Option<&str> {
+        self.if_match.as_deref()
+    }
+
     /// Set the If-None-Match of the option
     pub fn with_if_none_match(mut self, if_none_match: &str) -> Self {
         self.if_none_match = Some(if_none_match.to_string());
@@ -309,6 +333,7 @@ pub struct OpWrite {
     content_type: Option<String>,
     content_disposition: Option<String>,
     cache_control: Option<String>,
+    if_match: Option<String>,
 }
 
 impl OpWrite {
@@ -360,6 +385,17 @@ impl OpWrite {
         self.cache_control = Some(cache_control.to_string());
         self
     }
+
+    /// Set the If-Match of the option
+    pub fn with_if_match(mut self, if_match: &str) -> Self {
+        self.if_match = Some(if_match.to_string());
+        self
+    }
+
+    /// Get If-Match from option
+    pub fn if_match(&self) -> Option<&str> {
+        self.if_match.as_deref()
+    }
 }
 
 /// Args for `copy` operation.

Reply via email to