radiance_libmpv/mpv/
errors.rs1use std::{error, ffi::NulError, fmt, os::raw as ctype, rc::Rc, str::Utf8Error};
20
21#[allow(missing_docs)]
22pub type Result<T> = ::std::result::Result<T, Error>;
23
24#[derive(Clone, Debug, PartialEq, Eq, Hash)]
25pub enum Error {
26 Loadfiles {
27 index: usize,
28 error: Rc<Error>,
29 },
30 VersionMismatch {
31 linked: ctype::c_ulong,
32 loaded: ctype::c_ulong,
33 },
34 InvalidUtf8,
35 Null,
36 Raw(crate::MpvError),
37}
38
39impl fmt::Display for Error {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
41 write!(f, "{:?}", self)
42 }
43}
44
45impl From<NulError> for Error {
46 fn from(_other: NulError) -> Error {
47 Error::Null
48 }
49}
50
51impl From<Utf8Error> for Error {
52 fn from(_other: Utf8Error) -> Error {
53 Error::InvalidUtf8
54 }
55}
56impl From<crate::MpvError> for Error {
57 fn from(other: crate::MpvError) -> Error {
58 Error::Raw(other)
59 }
60}
61
62impl error::Error for Error {}