mkv_element/
error.rs

1use crate::base::VInt64;
2
3/// Error types for this crate.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7    /// I/O error, from `std::io::Error`.
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10
11    /// Invalid variable-length integer encoding, incidicates a vint longer than 8 bytes.
12    #[error("Invalid variable-length integer encoding, 8 leading zeros found...")]
13    InvalidVInt,
14
15    /// Attempted to read past the end of the buffer.
16    #[error("Attempted to read past the end of the buffer")]
17    OutOfBounds,
18
19    /// Attempted to read past the end of the buffer during element body decoding.
20    #[error("Element body over decode, ID: {0}")]
21    OverDecode(VInt64),
22
23    /// Not all bytes were consumed in a element body
24    #[error("Short read: not all bytes were consumed")]
25    ShortRead,
26
27    /// Not all bytes were consumed in a element body during element body decoding.
28    #[error("Element body under decode, ID: {0}")]
29    UnderDecode(VInt64),
30
31    /// Missing element.
32    #[error("Missing element, ID: {0}")]
33    MissingElement(VInt64),
34
35    /// Duplicate element in a master element.
36    #[error("Duplicate element {id} in master element {parent}")]
37    DuplicateElement {
38        /// The duplicate element ID.
39        id: VInt64,
40        /// The parent master element ID.
41        parent: VInt64,
42    },
43
44    /// Element body size is unknown.
45    #[error("Element body size is unknown, ID: {0}")]
46    ElementBodySizeUnknown(VInt64),
47
48    /// Malformed lacing data.
49    #[error("Malformed lacing data")]
50    MalformedLacingData,
51}
52
53/// Result type for this crate.
54pub type Result<T> = std::result::Result<T, Error>;