Skip to content
Merged
Show file tree
Hide file tree
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
94 changes: 93 additions & 1 deletion core/src/raw/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//!
//! By using ops, users can add more context for operation.

use crate::raw::*;
use crate::{options, raw::*};
use chrono::{DateTime, Utc};
use std::collections::HashMap;
use std::time::Duration;
Expand Down Expand Up @@ -65,6 +65,14 @@ impl OpDelete {
}
}

impl From<options::DeleteOptions> for OpDelete {
fn from(value: options::DeleteOptions) -> Self {
Self {
version: value.version,
}
}
}

/// Args for `delete` operation.
///
/// The path must be normalized.
Expand Down Expand Up @@ -469,6 +477,54 @@ impl OpReader {
}
}

impl From<options::ReadOptions> for (OpRead, OpReader) {
fn from(value: options::ReadOptions) -> Self {
(
OpRead {
range: value.range,
if_match: value.if_match,
if_none_match: value.if_none_match,
if_modified_since: value.if_modified_since,
if_unmodified_since: value.if_unmodified_since,
override_content_type: value.override_content_type,
override_cache_control: value.override_cache_control,
override_content_disposition: value.override_content_disposition,
version: value.version,
},
OpReader {
// Ensure concurrent is at least 1
concurrent: value.concurrent.max(1),
chunk: value.chunk,
gap: value.gap,
},
)
}
}

impl From<options::ReaderOptions> for (OpRead, OpReader) {
fn from(value: options::ReaderOptions) -> Self {
(
OpRead {
range: BytesRange::default(),
if_match: value.if_match,
if_none_match: value.if_none_match,
if_modified_since: value.if_modified_since,
if_unmodified_since: value.if_unmodified_since,
override_content_type: None,
override_cache_control: None,
override_content_disposition: None,
version: value.version,
},
OpReader {
// Ensure concurrent is at least 1
concurrent: value.concurrent.max(1),
chunk: value.chunk,
gap: value.gap,
},
)
}
}

/// Args for `stat` operation.
#[derive(Debug, Clone, Default)]
pub struct OpStat {
Expand Down Expand Up @@ -578,6 +634,21 @@ impl OpStat {
}
}

impl From<options::StatOptions> for OpStat {
fn from(value: options::StatOptions) -> Self {
Self {
if_match: value.if_match,
if_none_match: value.if_none_match,
if_modified_since: value.if_modified_since,
if_unmodified_since: value.if_unmodified_since,
override_content_type: value.override_content_type,
override_cache_control: value.override_cache_control,
override_content_disposition: value.override_content_disposition,
version: value.version,
}
}
}

/// Args for `write` operation.
#[derive(Debug, Clone, Default)]
pub struct OpWrite {
Expand Down Expand Up @@ -754,6 +825,27 @@ impl OpWriter {
}
}

impl From<options::WriteOptions> for (OpWrite, OpWriter) {
fn from(value: options::WriteOptions) -> Self {
(
OpWrite {
append: value.append,
// Ensure concurrent is at least 1
concurrent: value.concurrent.max(1),
content_type: value.content_type,
content_disposition: value.content_disposition,
content_encoding: value.content_encoding,
cache_control: value.cache_control,
if_match: value.if_match,
if_none_match: value.if_none_match,
if_not_exists: value.if_not_exists,
user_metadata: value.user_metadata,
},
OpWriter { chunk: value.chunk },
)
}
}

/// Args for `copy` operation.
#[derive(Debug, Clone, Default)]
pub struct OpCopy {}
Expand Down
2 changes: 2 additions & 0 deletions core/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@ pub use scheme::Scheme;
mod capability;
pub use capability::Capability;

pub mod options;

mod context;
pub(crate) use context::*;
Loading
Loading