1#[cfg(feature = "fs")]
5use super::FsStore;
6#[cfg(any(test, feature = "memory-backend"))]
7use super::InMemoryStore;
8#[cfg(any(test, feature = "fs", feature = "memory-backend"))]
9use super::{ObjectStore, Result};
10#[cfg(feature = "async-source")]
11pub use crate::object::AsyncObjectSource;
12pub use crate::object::ObjectSource;
13#[cfg(any(test, feature = "fs", feature = "memory-backend"))]
14use crate::object::{Blob, ContentHash, State, StateId, Tree};
15
16#[cfg(any(test, feature = "fs", feature = "memory-backend"))]
17macro_rules! impl_object_source {
18 ($store:ty) => {
19 impl ObjectSource for $store {
20 #[inline]
21 fn get_tree(&self, hash: &ContentHash) -> Result<Option<Tree>> {
22 ObjectStore::get_tree(self, hash)
23 }
24
25 #[inline]
26 fn get_state(&self, id: &StateId) -> Result<Option<State>> {
27 ObjectStore::get_state(self, id)
28 }
29
30 #[inline]
31 fn get_blob(&self, hash: &ContentHash) -> Result<Option<Blob>> {
32 ObjectStore::get_blob(self, hash)
33 }
34
35 #[inline]
36 fn decoded_blob_len(&self, hash: &ContentHash) -> Result<Option<u64>> {
37 ObjectStore::blob_size(self, hash)
38 }
39
40 #[inline]
41 fn get_blob_bytes(&self, hash: &ContentHash) -> Result<Option<bytes::Bytes>> {
42 ObjectStore::get_blob_bytes(self, hash)
43 }
44 }
45 };
46}
47
48#[cfg(feature = "fs")]
49impl_object_source!(FsStore);
50#[cfg(any(test, feature = "memory-backend"))]
51impl_object_source!(InMemoryStore);