vlc_rc/
error.rs

1//! Crate-level error types and handling.
2
3use std::io::Error as IoError;
4use std::num::ParseFloatError;
5use std::num::ParseIntError;
6
7/// An error that can occur when working with the VLC interface.
8#[derive(Debug)]
9pub enum Error {
10    /// A standard **I/O** error.
11    Io(IoError),
12    /// The client failed to parse output received from VLC.
13    ParseErr,
14}
15
16impl std::fmt::Display for Error {
17    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18        match *self {
19            Error::Io(ref e) => e.fmt(f),
20            Error::ParseErr => write!(
21                f,
22                "the client failed to parse the output received from VLC"
23            ),
24        }
25    }
26}
27
28impl From<IoError> for Error {
29    fn from(e: IoError) -> Self {
30        Error::Io(e)
31    }
32}
33
34impl From<ParseFloatError> for Error {
35    fn from(_: ParseFloatError) -> Self {
36        Error::ParseErr
37    }
38}
39
40impl From<ParseIntError> for Error {
41    fn from(_: ParseIntError) -> Self {
42        Error::ParseErr
43    }
44}