files_diff/
error.rs

1/// Errors that can occur during differing and patching operations.
2///
3/// This enum represents all possible errors that can occur when generating or
4/// applying patches, including algorithm-specific errors, hash validation
5/// failures, and I/O operations.
6///
7/// # Example
8/// ```rust
9/// use files_diff::{diff, DiffAlgorithm, CompressAlgorithm};
10///
11/// let before = b"original";
12/// let after = b"modified";
13///
14/// match diff(before, after, DiffAlgorithm::Rsync020, CompressAlgorithm::Zstd) {
15///     Ok(patch) => println!("Patch generated successfully"),
16///     Err(e) => match e {
17///         files_diff::Error::IoError(msg) => eprintln!("IO error: {}", msg),
18///         files_diff::Error::BeforeHashMismatch => eprintln!("Source file corrupted"),
19///         _ => eprintln!("Other error: {:?}", e),
20///     }
21/// }
22/// ```
23#[derive(Debug)]
24pub enum Error {
25    /// An error occurred in the rsync diff algorithm
26    RsyncDiffError(fast_rsync::DiffError),
27
28    /// An error occurred while applying an rsync patch
29    RsyncApplyError(fast_rsync::ApplyError),
30
31    /// An error occurred in the bidiff algorithm
32    BidiffError(String),
33
34    /// The hash of the source file doesn't match the expected hash
35    BeforeHashMismatch,
36
37    /// The hash of the generated file doesn't match the expected hash
38    AfterHashMismatch,
39
40    /// The hash of the operations doesn't match the expected hash
41    OperationsHashMismatch,
42
43    /// An I/O error occurred during file operations
44    IoError(String),
45
46    /// An error occurred while processing a zip archive
47    ZipError(String),
48
49    /// An error occurred while serializing a patch or patch set
50    SerializeError(rkyv::rancor::Error),
51
52    /// An error occurred while deserializing a patch or patch set
53    DeserializeError(rkyv::rancor::Error),
54}