1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use std::io;
#[derive(thiserror::Error, Debug)]
#[allow(missing_docs)]
pub enum Error {
#[error("An IO operation failed while streaming an entry")]
Io(#[from] io::Error),
#[error(transparent)]
PackParse(#[from] crate::data::header::decode::Error),
#[error("pack checksum in trailer was {expected}, but actual checksum was {actual}")]
ChecksumMismatch {
expected: git_hash::ObjectId,
actual: git_hash::ObjectId,
},
#[error("pack is incomplete: it was decompressed into {actual} bytes but {expected} bytes where expected.")]
IncompletePack { actual: u64, expected: u64 },
#[error("The object {object_id} could not be decoded or wasn't found")]
NotFound { object_id: git_hash::ObjectId },
}
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum Mode {
AsIs,
Verify,
Restore,
}
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum EntryDataMode {
Ignore,
Crc32,
Keep,
KeepAndCrc32,
}
impl EntryDataMode {
pub fn crc32(&self) -> bool {
match self {
EntryDataMode::KeepAndCrc32 | EntryDataMode::Crc32 => true,
EntryDataMode::Keep | EntryDataMode::Ignore => false,
}
}
pub fn keep(&self) -> bool {
match self {
EntryDataMode::Keep | EntryDataMode::KeepAndCrc32 => true,
EntryDataMode::Ignore | EntryDataMode::Crc32 => false,
}
}
}