From f791eeb99e49d64f6d663faa9db148c3e59afee3 Mon Sep 17 00:00:00 2001 From: STRRL Date: Mon, 17 Apr 2023 16:31:10 +0800 Subject: [PATCH] feat: add If-Match Support for OpRead, OpWrite, OpStat Signed-off-by: STRRL --- 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 84089e4489a..3d24f45e60b 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, override_cache_control: Option, + if_match: Option, if_none_match: Option, } @@ -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, if_none_match: Option, } @@ -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, content_disposition: Option, cache_control: Option, + if_match: Option, } 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.