mkv_element/
error.rs

1use crate::base::VInt64;
2
3/// Error types for this crate.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// I/O error, from `std::io::Error`.
7    #[error("I/O error: {0}")]
8    Io(#[from] std::io::Error),
9
10    /// Invalid variable-length integer encoding, incidicates a vint longer than 8 bytes.
11    #[error("Invalid variable-length integer encoding, 8 leading zeros found...")]
12    InvalidVInt,
13
14    /// Attempted to read past the end of the buffer.
15    #[error("Attempted to read past the end of the buffer")]
16    OutOfBounds,
17
18    /// Attempted to read past the end of the buffer during element body decoding.
19    #[error("Element body over decode, ID: {0}")]
20    OverDecode(VInt64),
21
22    /// Not all bytes were consumed in a element body
23    #[error("Short read: not all bytes were consumed")]
24    ShortRead,
25
26    /// Not all bytes were consumed in a element body during element body decoding.
27    #[error("Element body under decode, ID: {0}")]
28    UnderDecode(VInt64),
29}
30
31/// Result type for this crate.
32pub type Result<T> = std::result::Result<T, Error>;