1use crate::Cipher;
4use core::fmt;
5
6pub type Result<T> = core::result::Result<T, Error>;
8
9#[derive(Clone, Debug, Eq, PartialEq)]
11#[non_exhaustive]
12pub enum Error {
13 Crypto,
15
16 KeySize,
18
19 Length,
21
22 IvSize,
24
25 TagSize,
27
28 UnsupportedCipher(Cipher),
30}
31
32impl fmt::Display for Error {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 match self {
35 Error::Crypto => write!(f, "cryptographic error"),
36 Error::KeySize => write!(f, "invalid key size"),
37 Error::Length => write!(f, "invalid input length"),
38 Error::IvSize => write!(f, "invalid initialization vector size"),
39 Error::TagSize => write!(f, "invalid AEAD tag size"),
40 Error::UnsupportedCipher(cipher) => write!(f, "unsupported cipher: {}", cipher),
41 }
42 }
43}
44
45impl core::error::Error for Error {}