Files
radicle-git/archived/link-git/src/odb/backend.rs
T
Fintan Halpenny 1668d9fab3 Archive crates
Move git-commit, git-trailers, and link-git to an archived directory
to hide them away -- showing the intent that radicle-git-ext will be
the main crate for git functionality.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-27 11:01:21 +01:00

37 lines
887 B
Rust

// Copyright © 2021 The Radicle Link Contributors
//
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
// Linking Exception. For full terms see the included LICENSE file.
use git_hash::oid;
use git_pack::{cache::DecodeEntry, data::Object};
use super::{index, pack, window};
pub type Loose = git_odb::loose::Store;
pub struct Packed<I, D> {
pub index: I,
pub data: D,
}
impl<I, D> Packed<I, D>
where
I: index::Index,
D: window::Cache,
{
pub fn contains(&self, id: impl AsRef<oid>) -> bool {
self.index.contains(id)
}
pub fn find<'a>(
&self,
id: impl AsRef<oid>,
buf: &'a mut Vec<u8>,
cache: &mut impl DecodeEntry,
) -> Result<Option<Object<'a>>, index::error::Lookup<pack::error::Data>> {
self.index
.lookup(|info| self.data.get(info), id, buf, cache)
}
}