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