git_pack/bundle/
mod.rs

1///
2pub mod init;
3
4mod find;
5///
6#[cfg(not(feature = "wasm"))]
7pub mod write;
8
9///
10pub mod verify {
11    use std::sync::atomic::AtomicBool;
12
13    use git_features::progress::Progress;
14
15    ///
16    pub mod integrity {
17        /// Returned by [`Bundle::verify_integrity()`][crate::Bundle::verify_integrity()].
18        pub struct Outcome<P> {
19            /// The computed checksum of the index which matched the stored one.
20            pub actual_index_checksum: git_hash::ObjectId,
21            /// The packs traversal outcome
22            pub pack_traverse_outcome: crate::index::traverse::Statistics,
23            /// The provided progress instance.
24            pub progress: P,
25        }
26    }
27
28    use crate::Bundle;
29
30    impl Bundle {
31        /// Similar to [`crate::index::File::verify_integrity()`] but more convenient to call as the presence of the
32        /// pack file is a given.
33        pub fn verify_integrity<C, P, F>(
34            &self,
35            progress: P,
36            should_interrupt: &AtomicBool,
37            options: crate::index::verify::integrity::Options<F>,
38        ) -> Result<integrity::Outcome<P>, crate::index::traverse::Error<crate::index::verify::integrity::Error>>
39        where
40            P: Progress,
41            C: crate::cache::DecodeEntry,
42            F: Fn() -> C + Send + Clone,
43        {
44            self.index
45                .verify_integrity(
46                    Some(crate::index::verify::PackContext {
47                        data: &self.pack,
48                        options,
49                    }),
50                    progress,
51                    should_interrupt,
52                )
53                .map(|o| integrity::Outcome {
54                    actual_index_checksum: o.actual_index_checksum,
55                    pack_traverse_outcome: o.pack_traverse_statistics.expect("pack is set"),
56                    progress: o.progress,
57                })
58        }
59    }
60}