diff --git a/src/chunked.rs b/src/chunked.rs index 1775d95b..cbd66f62 100644 --- a/src/chunked.rs +++ b/src/chunked.rs @@ -61,6 +61,7 @@ impl Display for ChunkedStore { } #[async_trait] +#[deny(clippy::missing_trait_methods)] impl ObjectStore for ChunkedStore { async fn put_opts( &self, @@ -138,6 +139,9 @@ impl ObjectStore for ChunkedStore { self.inner.get_range(location, range).await } + async fn get_ranges(&self, location: &Path, ranges: &[Range]) -> Result> { + self.inner.get_ranges(location, ranges).await + } async fn head(&self, location: &Path) -> Result { self.inner.head(location).await } @@ -173,9 +177,17 @@ impl ObjectStore for ChunkedStore { self.inner.copy(from, to).await } + async fn rename(&self, from: &Path, to: &Path) -> Result<()> { + self.inner.rename(from, to).await + } + async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> { self.inner.copy_if_not_exists(from, to).await } + + async fn rename_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> { + self.inner.rename_if_not_exists(from, to).await + } } #[cfg(test)] diff --git a/src/lib.rs b/src/lib.rs index c3181d65..c4c39dcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -615,7 +615,7 @@ pub type MultipartId = String; /// Universal API to multiple object store services. /// -/// For more convience methods, check [`ObjectStoreExt`]. +/// For more convenience methods, check [`ObjectStoreExt`]. /// /// # Contract /// This trait is meant as a contract between object store implementations @@ -624,7 +624,57 @@ pub type MultipartId = String; /// /// The [`ObjectStoreExt`] acts as an API/contract between `object_store` /// and the store users and provides additional methods that may be simpler to use but overlap -/// in functionality with `ObjectStore` +/// in functionality with [`ObjectStore`]. +/// +/// # Wrappers +/// If you wrap an [`ObjectStore`] -- e.g. to add observability -- you SHOULD +/// implement all trait methods. This ensures that defaults implementations +/// that are overwritten by the wrapped store are also used by the wrapper. +/// For example: +/// +/// ```ignore +/// struct MyStore { +/// ... +/// } +/// +/// #[async_trait] +/// impl ObjectStore for MyStore { +/// // implement custom ranges handling +/// async fn get_ranges( +/// &self, +/// location: &Path, +/// ranges: &[Range], +/// ) -> Result> { +/// ... +/// } +/// +/// ... +/// } +/// +/// struct Wrapper { +/// inner: Arc, +/// } +/// +/// #[async_trait] +/// #[deny(clippy::missing_trait_methods)] +/// impl ObjectStore for Wrapper { +/// // If we would not implement this method, +/// // we would get the trait default and not +/// // use the actual implementation of `inner`. +/// async fn get_ranges( +/// &self, +/// location: &Path, +/// ranges: &[Range], +/// ) -> Result> { +/// ... +/// } +/// +/// ... +/// } +/// ``` +/// +/// To automatically detect this issue, use +/// [`#[deny(clippy::missing_trait_methods)]`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_trait_methods). #[async_trait] pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static { /// Save the provided `payload` to `location` with the given options @@ -1065,6 +1115,7 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static { macro_rules! as_ref_impl { ($type:ty) => { #[async_trait] + #[deny(clippy::missing_trait_methods)] impl ObjectStore for $type { async fn put_opts( &self, diff --git a/src/limit.rs b/src/limit.rs index 485a3089..a46ba569 100644 --- a/src/limit.rs +++ b/src/limit.rs @@ -70,6 +70,7 @@ impl std::fmt::Display for LimitStore { } #[async_trait] +#[deny(clippy::missing_trait_methods)] impl ObjectStore for LimitStore { async fn put_opts( &self, diff --git a/src/prefix.rs b/src/prefix.rs index 7b8d60dd..19d2ada4 100644 --- a/src/prefix.rs +++ b/src/prefix.rs @@ -93,6 +93,7 @@ fn strip_meta(prefix: &Path, meta: ObjectMeta) -> ObjectMeta { } #[async_trait::async_trait] +#[deny(clippy::missing_trait_methods)] impl ObjectStore for PrefixStore { async fn put_opts( &self, diff --git a/src/throttle.rs b/src/throttle.rs index d9c48554..8b6196ab 100644 --- a/src/throttle.rs +++ b/src/throttle.rs @@ -147,6 +147,7 @@ impl std::fmt::Display for ThrottledStore { } #[async_trait] +#[deny(clippy::missing_trait_methods)] impl ObjectStore for ThrottledStore { async fn put_opts( &self,