1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use std::io::Error as IoError; use std::str::Utf8Error; use term::Error as TermError; use term::terminfo::parm::Error as ParamError; #[derive(Debug)] pub enum Error { IoError(IoError), MissingCap(String), UnrecognizedEscapeSequence(Vec<u8>), Utf8Error(Utf8Error), NoSuchMenuPlace(String), TermError(TermError), ParamError(ParamError), } pub type Result<T> = ::std::result::Result<T, Error>; impl Error { pub fn last_os_error() -> Self { Error::IoError(IoError::last_os_error()) } } impl From<IoError> for Error { fn from(e: IoError) -> Self { Error::IoError(e) } } impl From<Utf8Error> for Error { fn from(e: Utf8Error) -> Self { Error::Utf8Error(e) } } impl From<TermError> for Error { fn from(e: TermError) -> Self { Error::TermError(e) } } impl From<ParamError> for Error { fn from(e: ParamError) -> Self { Error::ParamError(e) } }