alamb commented on code in PR #548:
URL:
https://github.com/apache/arrow-rs-object-store/pull/548#discussion_r2546735146
##########
src/lib.rs:
##########
@@ -1756,6 +1761,73 @@ pub struct PutResult {
pub version: Option<String>,
}
+/// Configure preconditions for the copy operation
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
+pub enum CopyMode {
+ /// Perform an atomic write operation, overwriting any object present at
the provided path
+ #[default]
+ Overwrite,
+ /// Perform an atomic write operation, returning [`Error::AlreadyExists`]
if an
+ /// object already exists at the provided path
+ Create,
+}
+
+/// Options for a copy request
+#[derive(Debug, Clone, Default)]
+pub struct CopyOptions {
+ /// Configure the [`CopyMode`] for this operation
+ pub mode: CopyMode,
+ /// Implementation-specific extensions. Intended for use by
[`ObjectStore`] implementations
+ /// that need to pass context-specific information (like tracing spans)
via trait methods.
+ ///
+ /// These extensions are ignored entirely by backends offered through this
crate.
+ ///
+ /// They are also excluded from [`PartialEq`] and [`Eq`].
+ pub extensions: Extensions,
+}
+
+impl CopyOptions {
+ /// Create a new [`CopyOptions`]
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ /// Sets the `mode.
+ ///
+ /// See [`CopyOptions::mode`].
+ #[must_use]
+ pub fn with_mode(mut self, mode: CopyMode) -> Self {
+ self.mode = mode;
+ self
+ }
+
+ /// Sets the `extensions`.
+ ///
+ /// See [`CopyOptions::extensions`].
+ #[must_use]
+ pub fn with_extensions(mut self, extensions: Extensions) -> Self {
+ self.extensions = extensions;
+ self
+ }
+}
Review Comment:
I recommend also adding accessors and remove the `pub` from the fields for
the reasons listed above
##########
src/lib.rs:
##########
@@ -1633,7 +1638,7 @@ pub struct PutOptions {
///
/// These extensions are ignored entirely by backends offered through this
crate.
///
- /// They are also eclused from [`PartialEq`] and [`Eq`].
+ /// They are also excluded from [`PartialEq`] and [`Eq`].
Review Comment:
👍
##########
src/lib.rs:
##########
@@ -1756,6 +1761,73 @@ pub struct PutResult {
pub version: Option<String>,
}
+/// Configure preconditions for the copy operation
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
+pub enum CopyMode {
+ /// Perform an atomic write operation, overwriting any object present at
the provided path
+ #[default]
+ Overwrite,
+ /// Perform an atomic write operation, returning [`Error::AlreadyExists`]
if an
+ /// object already exists at the provided path
+ Create,
+}
+
+/// Options for a copy request
+#[derive(Debug, Clone, Default)]
+pub struct CopyOptions {
+ /// Configure the [`CopyMode`] for this operation
+ pub mode: CopyMode,
Review Comment:
If we make all these fields `pub` I don't think we will be able to add new
fields (e.g a different target object store) without a breaking API change
So I would suggest either marking these as non-pub or marking the struct as
[`non_exhaustitve`](https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]