Skip to main content

vsc/
error.rs

1//! Error type for the VSS reader.
2
3/// An error decoding a Volume Shadow Copy volume.
4///
5/// The reader never panics on malformed input: out-of-range reads yield safe
6/// defaults through the bounds-checked helpers, and only genuine I/O failures or
7/// caller misuse (an out-of-range store index) surface as an error.
8#[derive(Debug, thiserror::Error)]
9pub enum VssError {
10    /// An I/O error reading the underlying volume.
11    #[error("i/o error reading VSS volume: {0}")]
12    Io(#[from] std::io::Error),
13
14    /// A store index passed to [`crate::VssVolume::store_info`] is past the end
15    /// of the enumerated stores.
16    #[error("store index {index} out of range ({count} store(s) enumerated)")]
17    StoreIndexOutOfRange {
18        /// The requested index.
19        index: usize,
20        /// The number of stores actually present.
21        count: usize,
22    },
23
24    /// The store has no catalog type-0x03 pointer, so its store-information
25    /// block cannot be located (e.g. a Windows 2003 R2 catalog).
26    #[error("store {index} has no store-information pointer (no catalog type-0x03 entry)")]
27    StoreInfoUnavailable {
28        /// The store index whose pointer is missing.
29        index: usize,
30    },
31
32    /// A store-header offset read from the catalog runs past the end of the
33    /// volume — consistent with a corrupt or tampered catalog entry.
34    #[error("store {index} header offset {offset} runs past the {volume_size}-byte volume")]
35    StoreOffsetOutOfBounds {
36        /// The store index whose pointer is out of range.
37        index: usize,
38        /// The offending offset.
39        offset: u64,
40        /// The volume size the offset exceeded.
41        volume_size: u64,
42    },
43}