summaryrefslogtreecommitdiffstats
path: root/vendor/gix-odb/src/cache.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix-odb/src/cache.rs')
-rw-r--r--vendor/gix-odb/src/cache.rs38
1 files changed, 15 insertions, 23 deletions
diff --git a/vendor/gix-odb/src/cache.rs b/vendor/gix-odb/src/cache.rs
index 8e108646f..87c8da4ed 100644
--- a/vendor/gix-odb/src/cache.rs
+++ b/vendor/gix-odb/src/cache.rs
@@ -133,7 +133,7 @@ impl<S> DerefMut for Cache<S> {
}
mod impls {
- use std::{io::Read, ops::DerefMut};
+ use std::{cell::RefCell, io::Read, ops::DerefMut};
use gix_hash::{oid, ObjectId};
use gix_object::{Data, Kind};
@@ -145,9 +145,7 @@ mod impls {
where
S: crate::Write,
{
- type Error = S::Error;
-
- fn write_stream(&self, kind: Kind, size: u64, from: impl Read) -> Result<ObjectId, Self::Error> {
+ fn write_stream(&self, kind: Kind, size: u64, from: &mut dyn Read) -> Result<ObjectId, crate::write::Error> {
self.inner.write_stream(kind, size, from)
}
}
@@ -156,13 +154,11 @@ mod impls {
where
S: gix_pack::Find,
{
- type Error = S::Error;
-
- fn contains(&self, id: impl AsRef<oid>) -> bool {
+ fn contains(&self, id: &oid) -> bool {
self.inner.contains(id)
}
- fn try_find<'a>(&self, id: impl AsRef<oid>, buffer: &'a mut Vec<u8>) -> Result<Option<Data<'a>>, Self::Error> {
+ fn try_find<'a>(&self, id: &oid, buffer: &'a mut Vec<u8>) -> Result<Option<Data<'a>>, crate::find::Error> {
gix_pack::Find::try_find(self, id, buffer).map(|t| t.map(|t| t.0))
}
}
@@ -171,9 +167,7 @@ mod impls {
where
S: crate::Header,
{
- type Error = S::Error;
-
- fn try_header(&self, id: impl AsRef<oid>) -> Result<Option<Header>, Self::Error> {
+ fn try_header(&self, id: &oid) -> Result<Option<Header>, crate::find::Error> {
self.inner.try_header(id)
}
}
@@ -182,18 +176,16 @@ mod impls {
where
S: gix_pack::Find,
{
- type Error = S::Error;
-
- fn contains(&self, id: impl AsRef<oid>) -> bool {
+ fn contains(&self, id: &oid) -> bool {
self.inner.contains(id)
}
fn try_find<'a>(
&self,
- id: impl AsRef<oid>,
+ id: &oid,
buffer: &'a mut Vec<u8>,
- ) -> Result<Option<(Data<'a>, Option<Location>)>, Self::Error> {
- match self.pack_cache.as_ref().map(|rc| rc.borrow_mut()) {
+ ) -> Result<Option<(Data<'a>, Option<Location>)>, crate::find::Error> {
+ match self.pack_cache.as_ref().map(RefCell::borrow_mut) {
Some(mut pack_cache) => self.try_find_cached(id, buffer, pack_cache.deref_mut()),
None => self.try_find_cached(id, buffer, &mut gix_pack::cache::Never),
}
@@ -201,25 +193,25 @@ mod impls {
fn try_find_cached<'a>(
&self,
- id: impl AsRef<oid>,
+ id: &oid,
buffer: &'a mut Vec<u8>,
- pack_cache: &mut impl gix_pack::cache::DecodeEntry,
- ) -> Result<Option<(Data<'a>, Option<gix_pack::data::entry::Location>)>, Self::Error> {
- if let Some(mut obj_cache) = self.object_cache.as_ref().map(|rc| rc.borrow_mut()) {
+ pack_cache: &mut dyn gix_pack::cache::DecodeEntry,
+ ) -> Result<Option<(Data<'a>, Option<gix_pack::data::entry::Location>)>, crate::find::Error> {
+ if let Some(mut obj_cache) = self.object_cache.as_ref().map(RefCell::borrow_mut) {
if let Some(kind) = obj_cache.get(&id.as_ref().to_owned(), buffer) {
return Ok(Some((Data::new(kind, buffer), None)));
}
}
let possibly_obj = self.inner.try_find_cached(id.as_ref(), buffer, pack_cache)?;
if let (Some(mut obj_cache), Some((obj, _location))) =
- (self.object_cache.as_ref().map(|rc| rc.borrow_mut()), &possibly_obj)
+ (self.object_cache.as_ref().map(RefCell::borrow_mut), &possibly_obj)
{
obj_cache.put(id.as_ref().to_owned(), obj.kind, obj.data);
}
Ok(possibly_obj)
}
- fn location_by_oid(&self, id: impl AsRef<oid>, buf: &mut Vec<u8>) -> Option<gix_pack::data::entry::Location> {
+ fn location_by_oid(&self, id: &oid, buf: &mut Vec<u8>) -> Option<gix_pack::data::entry::Location> {
self.inner.location_by_oid(id, buf)
}