1use crate::raw;
2use std::error;
3use std::fmt;
4use std::io;
5
6pub type Result<T> = ::std::result::Result<T, Error>;
8
9#[derive(Debug)]
11pub enum Error {
12 Fst(raw::Error),
15 Io(io::Error),
17}
18
19impl From<io::Error> for Error {
20 #[inline]
21 fn from(err: io::Error) -> Error {
22 Error::Io(err)
23 }
24}
25
26impl From<raw::Error> for Error {
27 #[inline]
28 fn from(err: raw::Error) -> Error {
29 Error::Fst(err)
30 }
31}
32
33impl fmt::Display for Error {
34 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
35 use self::Error::*;
36 match *self {
37 Fst(ref err) => err.fmt(f),
38 Io(ref err) => err.fmt(f),
39 }
40 }
41}
42
43impl error::Error for Error {
44 fn cause(&self) -> Option<&dyn error::Error> {
45 use self::Error::*;
46 match *self {
47 Fst(ref err) => Some(err),
48 Io(ref err) => Some(err),
49 }
50 }
51}