History

Implement `git_odb::Find` for `git_odb::Handle`

Sebastian Thiel committed 4 years ago

Commit 3522aef1 parent 15b83723 files · +22 −6Browse files

Unified · Split

3 files
  1. git-odb/src/cache.rs +3 −3
  2. git-odb/src/store_impls/dynamic/find.rs +18 −2
  3. git-odb/src/store_impls/linked/find.rs +1 −1
git-odb/src/cache.rs+3−3
@@ -124,7 +124,7 @@ mod impls { · 123 unmodified lines
124 124
125 impl<S> crate::Find for Cache<S>125 impl<S> crate::Find for Cache<S>
126 where126 where
127 S: crate::pack::Find,127 S: git_pack::Find,
128 {128 {
129 type Error = S::Error;129 type Error = S::Error;
130 130
@@ -137,9 +137,9 @@ mod impls { · 6 unmodified lines
137 }137 }
138 }138 }
139 139
140 impl<S> crate::pack::Find for Cache<S>140 impl<S> git_pack::Find for Cache<S>
141 where141 where
142 S: crate::pack::Find,142 S: git_pack::Find,
143 {143 {
144 type Error = S::Error;144 type Error = S::Error;
145 145
git-odb/src/store_impls/dynamic/find.rs+18−2
@@ -9,7 +9,7 @@ use crate::store::handle; · 8 unmodified lines
9mod error {9mod error {
10 use crate::{loose, pack};10 use crate::{loose, pack};
11 11
12 /// Returned by [`Handle::try_find()`][crate::pack::Find::try_find()]12 /// Returned by [`Handle::try_find()`][git_pack::Find::try_find()]
13 #[derive(thiserror::Error, Debug)]13 #[derive(thiserror::Error, Debug)]
14 #[allow(missing_docs)]14 #[allow(missing_docs)]
15 pub enum Error {15 pub enum Error {
@@ -27,7 +27,7 @@ pub use error::Error; · 11 unmodified lines
27 27
28use crate::store::types::PackId;28use crate::store::types::PackId;
29 29
30impl<S> crate::pack::Find for super::Handle<S>30impl<S> git_pack::Find for super::Handle<S>
31where31where
32 S: Deref<Target = super::Store> + Clone,32 S: Deref<Target = super::Store> + Clone,
33{33{
@@ -304,3 +304,19 @@ where · 270 unmodified lines
304 }304 }
305 }305 }
306}306}
307
308impl<S> crate::Find for super::Handle<S>
309where
310 S: Deref<Target = super::Store> + Clone,
311 Self: git_pack::Find,
312{
313 type Error = <Self as git_pack::Find>::Error;
314
315 fn contains(&self, id: impl AsRef<oid>) -> bool {
316 git_pack::Find::contains(self, id)
317 }
318
319 fn try_find<'a>(&self, id: impl AsRef<oid>, buffer: &'a mut Vec<u8>) -> Result<Option<Data<'a>>, Self::Error> {
320 git_pack::Find::try_find(self, id, buffer).map(|t| t.map(|t| t.0))
321 }
322}
git-odb/src/store_impls/linked/find.rs+1−1
@@ -9,7 +9,7 @@ use crate::{ · 8 unmodified lines
9 store_impls::{compound, linked},9 store_impls::{compound, linked},
10};10};
11 11
12impl crate::pack::Find for linked::Store {12impl git_pack::Find for linked::Store {
13 type Error = compound::find::Error;13 type Error = compound::find::Error;
14 14
15 /// Return true if the given object `id` is contained in the store.15 /// Return true if the given object `id` is contained in the store.