mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-11-16 08:10:41 +08:00
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
37 lines
887 B
Rust
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)
|
|
}
|
|
}
|