Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add If-Match Support for OpRead, OpWrite, OpStat #2017

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions core/src/types/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand Down Expand Up @@ -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());
Expand All @@ -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>,
}

Expand All @@ -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());
Expand All @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down