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,
}
}
}