simple-sigh 0.1.0

Simple signal handler, intended for examples.
Documentation
use std::{fmt, io};

#[derive(Debug)]
pub enum Error {
  IO(io::Error),
  Internal(String)
}

#[allow(clippy::needless_pass_by_value)]
impl Error {
  pub fn internal(s: impl ToString) -> Self {
    Self::Internal(s.to_string())
  }
}

impl std::error::Error for Error {}

impl From<io::Error> for Error {
  fn from(err: io::Error) -> Self {
    Self::IO(err)
  }
}

impl fmt::Display for Error {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    match self {
      Self::IO(e) => write!(f, "I/O error; {e}"),
      Self::Internal(e) => write!(f, "Internal error; {e}")
    }
  }
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :