lich 0.1.0

Minimal password management.
Documentation
use std::error::Error as StdError;
use std::fmt;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
    BadKey,
    Decrypt,
    Encrypt,
    BadEncryptionKey,
    DecodeString,
    Randomize,
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "Cryptographic error: {}.", self.description())
    }
}

impl StdError for Error {
    fn description(&self) -> &str {
        match *self {
            Error::BadKey => "bad key",
            Error::Decrypt => "could not decrypt",
            Error::Encrypt => "could not encrypt",
            Error::BadEncryptionKey => "bad encryption key",
            Error::DecodeString => "bad string encoding",
            Error::Randomize => "rng error",
        }
    }

    fn cause(&self) -> Option<&StdError> {
        None
    }
}