gix_pack/data/output/count/
mod.rs

1use gix_hash::ObjectId;
2
3use crate::data::output::Count;
4
5/// Specifies how the pack location was handled during counting
6#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub enum PackLocation {
9    /// We did not lookup this object
10    NotLookedUp,
11    /// The object was looked up and there may be a location in a pack, along with entry information
12    LookedUp(Option<crate::data::entry::Location>),
13}
14
15impl PackLocation {
16    /// Directly go through to `LookedUp` variant, panic otherwise
17    pub fn is_none(&self) -> bool {
18        match self {
19            PackLocation::LookedUp(opt) => opt.is_none(),
20            PackLocation::NotLookedUp => unreachable!("must have been resolved"),
21        }
22    }
23    /// Directly go through to `LookedUp` variant, panic otherwise
24    pub fn as_ref(&self) -> Option<&crate::data::entry::Location> {
25        match self {
26            PackLocation::LookedUp(opt) => opt.as_ref(),
27            PackLocation::NotLookedUp => unreachable!("must have been resolved"),
28        }
29    }
30}
31
32impl Count {
33    /// Create a new instance from the given `oid` and its corresponding location.
34    pub fn from_data(oid: impl Into<ObjectId>, location: Option<crate::data::entry::Location>) -> Self {
35        Count {
36            id: oid.into(),
37            entry_pack_location: PackLocation::LookedUp(location),
38        }
39    }
40}
41
42#[path = "objects/mod.rs"]
43mod objects_impl;
44pub use objects_impl::{objects, objects_unthreaded};
45
46///
47pub mod objects {
48    pub use super::objects_impl::{Error, ObjectExpansion, Options, Outcome};
49}