gix_odb/store_impls/dynamic/
mod.rs

1//! The standard object store which should fit all needs.
2use std::{cell::RefCell, ops::Deref};
3
4use gix_features::zlib;
5
6use crate::Store;
7
8/// This effectively acts like a handle but exists to be usable from the actual `crate::Handle` implementation which adds caches on top.
9/// Each store is quickly cloned and contains thread-local state for shared packs.
10pub struct Handle<S>
11where
12    S: Deref<Target = Store> + Clone,
13{
14    pub(crate) store: S,
15    /// Defines what happens when there is no more indices to load.
16    pub refresh: RefreshMode,
17    /// The maximum recursion depth for resolving ref-delta base objects, that is objects referring to other objects within
18    /// a pack.
19    /// Recursive loops are possible only in purposefully crafted packs.
20    /// This value doesn't have to be huge as in typical scenarios, these kind of objects are rare and chains supposedly are
21    /// even more rare.
22    pub max_recursion_depth: usize,
23
24    /// If true, replacements will not be performed even if these are available.
25    pub ignore_replacements: bool,
26
27    pub(crate) token: Option<handle::Mode>,
28    snapshot: RefCell<load_index::Snapshot>,
29    inflate: RefCell<zlib::Inflate>,
30    packed_object_count: RefCell<Option<u64>>,
31}
32
33/// Decide what happens when all indices are loaded.
34#[derive(Default, Clone, Copy)]
35pub enum RefreshMode {
36    /// Check for new or changed pack indices (and pack data files) when the last known index is loaded.
37    /// During runtime we will keep pack indices stable by never reusing them, however, there is the option for
38    /// clearing internal caches which is likely to change pack ids and it will trigger unloading of packs as they are missing on disk.
39    #[default]
40    AfterAllIndicesLoaded,
41    /// Use this if you expect a lot of missing objects that shouldn't trigger refreshes even after all packs are loaded.
42    /// This comes at the risk of not learning that the packs have changed in the mean time.
43    Never,
44}
45
46impl RefreshMode {
47    /// Set this refresh mode to never refresh.
48    pub fn never(&mut self) {
49        *self = RefreshMode::Never;
50    }
51}
52
53///
54pub mod find;
55
56///
57pub mod prefix;
58
59mod header;
60
61///
62pub mod iter;
63
64///
65pub mod write;
66
67///
68pub mod init;
69
70pub(crate) mod types;
71pub use types::Metrics;
72
73pub(crate) mod handle;
74
75///
76pub mod load_index;
77
78///
79pub mod verify;
80
81mod load_one;
82
83mod metrics;
84
85mod access;
86
87///
88pub mod structure;