Skip to content

Commit

Permalink
chore: fix comments and order
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-III committed Nov 27, 2024
1 parent 2f15d60 commit a302650
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions core/src/raw/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ pub struct OpWrite {
content_disposition: Option<String>,
cache_control: Option<String>,
executor: Option<Executor>,
if_none_match: Option<String>,
if_match: Option<String>,
if_none_match: Option<String>,
if_not_exists: bool,
user_metadata: Option<HashMap<String, String>>,
}
Expand Down Expand Up @@ -665,17 +665,6 @@ impl OpWrite {
self
}

/// Set the If-None-Match of the option
pub fn with_if_none_match(mut self, s: &str) -> Self {
self.if_none_match = Some(s.to_string());
self
}

/// Get If-None-Match from option
pub fn if_none_match(&self) -> Option<&str> {
self.if_none_match.as_deref()
}

/// Set the If-Match of the option
pub fn with_if_match(mut self, s: &str) -> Self {
self.if_match = Some(s.to_string());
Expand All @@ -687,6 +676,17 @@ impl OpWrite {
self.if_match.as_deref()
}

/// Set the If-None-Match of the option
pub fn with_if_none_match(mut self, s: &str) -> Self {
self.if_none_match = Some(s.to_string());
self
}

/// Get If-None-Match from option
pub fn if_none_match(&self) -> Option<&str> {
self.if_none_match.as_deref()
}

/// Set the If-Not-Exist of the option
pub fn with_if_not_exists(mut self, b: bool) -> Self {
self.if_not_exists = b;
Expand Down
6 changes: 3 additions & 3 deletions core/src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,8 +1430,8 @@ impl Operator {
///
/// ### Behavior
///
/// - If the target file's ETag does not match the specified one, returns [`ErrorKind::ConditionNotMatch`]
/// - If the target file's ETag matches the specified one, proceeds with the write operation
/// - If the target file's ETag does not match the specified one, returns [`ErrorKind::ConditionNotMatch`]
///
/// This operation will succeed when the target's ETag matches the specified one,
/// providing a way for conditional writes.
Expand All @@ -1441,9 +1441,9 @@ impl Operator {
/// ```no_run
/// # use opendal::{ErrorKind, Result};
/// use opendal::Operator;
/// # async fn test(op: Operator, etag: &str) -> Result<()> {
/// # async fn test(op: Operator, incorrect_etag: &str) -> Result<()> {
/// let bs = b"hello, world!".to_vec();
/// let res = op.write_with("path/to/file", bs).if_match(etag).await;
/// let res = op.write_with("path/to/file", bs).if_match(incorrect_etag).await;
/// assert!(res.is_err());
/// assert_eq!(res.unwrap_err().kind(), ErrorKind::ConditionNotMatch);
/// # Ok(())
Expand Down

0 comments on commit a302650

Please sign in to comment.