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
12 changes: 12 additions & 0 deletions src/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Display for ChunkedStore {
}

#[async_trait]
#[deny(clippy::missing_trait_methods)]
impl ObjectStore for ChunkedStore {
async fn put_opts(
&self,
Expand Down Expand Up @@ -138,6 +139,9 @@ impl ObjectStore for ChunkedStore {
self.inner.get_range(location, range).await
}

async fn get_ranges(&self, location: &Path, ranges: &[Range<u64>]) -> Result<Vec<Bytes>> {
self.inner.get_ranges(location, ranges).await
}
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
self.inner.head(location).await
}
Expand Down Expand Up @@ -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)]
Expand Down
55 changes: 53 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<u64>],
/// ) -> Result<Vec<Bytes>> {
/// ...
/// }
///
/// ...
/// }
///
/// struct Wrapper {
/// inner: Arc<dyn ObjectStore>,
/// }
///
/// #[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<u64>],
/// ) -> Result<Vec<Bytes>> {
/// ...
/// }
///
/// ...
/// }
/// ```
///
/// 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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl<T: ObjectStore> std::fmt::Display for LimitStore<T> {
}

#[async_trait]
#[deny(clippy::missing_trait_methods)]
impl<T: ObjectStore> ObjectStore for LimitStore<T> {
async fn put_opts(
&self,
Expand Down
1 change: 1 addition & 0 deletions src/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn strip_meta(prefix: &Path, meta: ObjectMeta) -> ObjectMeta {
}

#[async_trait::async_trait]
#[deny(clippy::missing_trait_methods)]
impl<T: ObjectStore> ObjectStore for PrefixStore<T> {
async fn put_opts(
&self,
Expand Down
1 change: 1 addition & 0 deletions src/throttle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl<T: ObjectStore> std::fmt::Display for ThrottledStore<T> {
}

#[async_trait]
#[deny(clippy::missing_trait_methods)]
impl<T: ObjectStore> ObjectStore for ThrottledStore<T> {
async fn put_opts(
&self,
Expand Down