gpio_utils/
error.rs

1// Copyright (c) 2018, The gpio-utils Authors.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/license/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option.  This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use nix::Error as NixError;
10use std::io::Error as IoError;
11use sysfs_gpio::Error as GpioError;
12
13#[derive(thiserror::Error, Debug)]
14pub enum Error {
15    #[error(transparent)]
16    Gpio(#[from] GpioError),
17    #[error(transparent)]
18    Nix(#[from] NixError),
19    #[error(transparent)]
20    Io(#[from] IoError),
21    #[error("{0}")]
22    Msg(String),
23}
24
25impl From<String> for Error {
26    fn from(msg: String) -> Error {
27        Error::Msg(msg)
28    }
29}
30
31pub type Result<T> = std::result::Result<T, Error>;