mbrobbel commented on code in PR #405:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/405#discussion_r2490691528


##########
src/lib.rs:
##########
@@ -901,6 +900,40 @@ macro_rules! as_ref_impl {
 as_ref_impl!(Arc<dyn ObjectStore>);
 as_ref_impl!(Box<dyn ObjectStore>);
 
+/// Helper module to [seal 
traits](https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/).
+mod private {
+    pub trait Sealed {}
+
+    impl<T> Sealed for T where T: super::ObjectStore + ?Sized {}
+}
+
+/// Extension trait for [`ObjectStore`] with convinience functions.
+///
+/// See "contract" section within the [`ObjectStore`] documentation for more 
reasoning.
+///
+/// # Implementation
+/// You MUST NOT implement this trait yourself. It is automatically 
implemented for all [`ObjectStore`] implementations.
+#[async_trait]
+pub trait ObjectStoreExt: private::Sealed {
+    /// Save the provided bytes to the specified location
+    ///
+    /// The operation is guaranteed to be atomic, it will either successfully
+    /// write the entirety of `payload` to `location`, or fail. No clients
+    /// should be able to observe a partially written object
+    async fn put(&self, location: &Path, payload: PutPayload) -> 
Result<PutResult>;
+}
+
+#[async_trait]
+impl<T> ObjectStoreExt for T
+where
+    T: ObjectStore + private::Sealed + ?Sized,

Review Comment:
   `ObjectStore` should be a supertrait of `ObjectStoreExt`:
   
   ```rust
   trait ObjectStoreExt: ObjectStore {}
   ```
   
   ```
   error[E0277]: the trait bound `u8: ObjectStore` is not satisfied
     --> src/main.rs:12:25
      |
   12 | impl ObjectStoreExt for u8 {}
      |                         ^^ the trait `ObjectStore` is not implemented 
for `u8`
      |
      = help: the trait `ObjectStore` is implemented for `Store`
   note: required by a bound in `ObjectStoreExt`
     --> src/main.rs:7:23
      |
    7 | trait ObjectStoreExt: ObjectStore {}
      |                       ^^^^^^^^^^^ required by this bound in 
`ObjectStoreExt`
   ```



-- 
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]

Reply via email to