vapoursynth/map/
errors.rs

1use std::ffi::NulError;
2use std::result;
3
4use thiserror::Error;
5
6/// The error type for `Map` operations.
7#[derive(Error, Debug, Eq, PartialEq)]
8pub enum Error {
9    #[error("The requested key wasn't found in the map")]
10    KeyNotFound,
11    #[error("The requested index was out of bounds")]
12    IndexOutOfBounds,
13    #[error("The given/requested value type doesn't match the type of the property")]
14    WrongValueType,
15    #[error("The key is invalid")]
16    InvalidKey(#[from] InvalidKeyError),
17    #[error("Couldn't convert to a CString")]
18    CStringConversion(#[from] NulError),
19    #[error("An unexpected error occurred")]
20    UnknownError,
21}
22
23/// A specialized `Result` type for `Map` operations.
24pub type Result<T> = result::Result<T, Error>;
25
26/// An error indicating the map key is invalid.
27#[derive(Error, Debug, Eq, PartialEq)]
28#[rustfmt::skip]
29pub enum InvalidKeyError {
30    #[error("The key is empty")]
31    EmptyKey,
32    #[error("The key contains an invalid character at index {}", _0)]
33    InvalidCharacter(usize),
34}