This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git
The following commit(s) were added to refs/heads/main by this push:
new 26cad7d Implement ObjectStore for Arc<T> and Box<T> (#526)
26cad7d is described below
commit 26cad7df680ae3f0ac32fe13e01c482e741a3916
Author: Wyatt Herkamp <[email protected]>
AuthorDate: Thu Dec 4 07:18:59 2025 -0500
Implement ObjectStore for Arc<T> and Box<T> (#526)
* Add `?Sized` bound to as_ref_impl
* Add Tests
* Fix Test
* Fix errors
---
src/lib.rs | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index 9b59627..736f173 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1055,7 +1055,7 @@ macro_rules! as_ref_impl {
($type:ty) => {
#[async_trait]
#[deny(clippy::missing_trait_methods)]
- impl ObjectStore for $type {
+ impl<T: ObjectStore + ?Sized> ObjectStore for $type {
async fn put_opts(
&self,
location: &Path,
@@ -1127,8 +1127,8 @@ macro_rules! as_ref_impl {
};
}
-as_ref_impl!(Arc<dyn ObjectStore>);
-as_ref_impl!(Box<dyn ObjectStore>);
+as_ref_impl!(Arc<T>);
+as_ref_impl!(Box<T>);
/// Extension trait for [`ObjectStore`] with convenience functions.
///
@@ -1957,9 +1957,8 @@ impl From<Error> for std::io::Error {
#[cfg(test)]
mod tests {
use super::*;
- use crate::buffered::BufWriter;
+
use chrono::TimeZone;
- use tokio::io::AsyncWriteExt;
macro_rules! maybe_skip_integration {
() => {
@@ -2011,6 +2010,9 @@ mod tests {
{
use bytes::Buf;
use serde::Deserialize;
+ use tokio::io::AsyncWriteExt;
+
+ use crate::buffered::BufWriter;
#[derive(Deserialize)]
struct Tagging {
@@ -2226,4 +2228,23 @@ mod tests {
assert!(options.head);
assert_eq!(options.extensions.get::<&str>(), extensions.get::<&str>());
}
+
+ fn takes_generic_object_store<T: ObjectStore>(store: T) {
+ // This function is just to ensure that the trait bounds are satisfied
+ let _ = store;
+ }
+ #[test]
+ fn test_dyn_impl() {
+ let store: Arc<dyn ObjectStore> = Arc::new(memory::InMemory::new());
+ takes_generic_object_store(store);
+ let store: Box<dyn ObjectStore> = Box::new(memory::InMemory::new());
+ takes_generic_object_store(store);
+ }
+ #[test]
+ fn test_generic_impl() {
+ let store = Arc::new(memory::InMemory::new());
+ takes_generic_object_store(store);
+ let store = Box::new(memory::InMemory::new());
+ takes_generic_object_store(store);
+ }
}