git_internal/internal/pack/
mod.rs

1//!
2//! ## Reference
3//! 1. Git Pack-Format [Introduce](https://git-scm.com/docs/pack-format)
4//!
5pub mod cache;
6pub mod cache_object;
7pub mod channel_reader;
8pub mod decode;
9pub mod encode;
10pub mod entry;
11pub mod utils;
12pub mod waitlist;
13pub mod wrapper;
14
15use std::sync::Arc;
16use std::sync::atomic::AtomicUsize;
17use threadpool::ThreadPool;
18
19use crate::hash::SHA1;
20use crate::internal::object::ObjectTrait;
21use crate::internal::pack::cache::Caches;
22use crate::internal::pack::waitlist::Waitlist;
23
24const DEFAULT_TMP_DIR: &str = "./.cache_temp";
25pub struct Pack {
26    pub number: usize,
27    pub signature: SHA1,
28    pub objects: Vec<Box<dyn ObjectTrait>>,
29    pub pool: Arc<ThreadPool>,
30    pub waitlist: Arc<Waitlist>,
31    pub caches: Arc<Caches>,
32    pub mem_limit: Option<usize>,
33    pub cache_objs_mem: Arc<AtomicUsize>, // the memory size of CacheObjects in this Pack
34    pub clean_tmp: bool,
35}
36
37#[cfg(test)]
38mod tests {
39    use tracing_subscriber::util::SubscriberInitExt;
40
41    pub(crate) fn init_logger() {
42        let _ = tracing_subscriber::fmt::Subscriber::builder()
43            .with_target(false)
44            .without_time()
45            .with_level(true)
46            .with_max_level(tracing::Level::DEBUG)
47            .finish()
48            .try_init(); // avoid multi-init
49
50        // CAUTION: This two is same
51        // 1.
52        // tracing_subscriber::fmt().init();
53        //
54        // 2.
55        // env::set_var("RUST_LOG", "debug"); // must be set if use `fmt::init()`, or no output
56        // tracing_subscriber::fmt::init();
57    }
58}