1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Cryptographic errors returned by this crate.
//!
//! All fallible functions expose their failure modes through
//!
//! ```rust,ignore
//! Result<T, CryptoError>
//! ```
//!
//! The variants wrap the underlying library’s error as a **plain string**
//! so that the public API stays stable even if the version of an
//! upstream crate changes. You can inspect the message or display the
//! error with [`std::fmt::Display`].
//!
//! | Variant | Origin crate | Typical cause |
//! |--------------------|--------------|---------------------------------------------------------------------------|
//! | `Argon2` | `argon2` | Key-derivation failed – e.g. invalid parameters or not enough memory. |
//! | `Aes256Gcm` | `aes-gcm` | Encryption/decryption failure. Most often: wrong password or tampering. |
//! | `Utf8` | `std` | Decrypted bytes were not valid UTF-8. |
//! | `BaseUrlDecode` | `base64` | The ciphertext string was not valid Base64URL. |
//! | `Decode` | internal | The decoded blob had an unexpected length/format. |
//!
//! ## Example
//! ```rust
//! use encryptor::{encrypt, decrypt, CryptoError};
//!
//! match decrypt("bad blob", "pass") {
//! Err(CryptoError::BaseUrlDecode(e)) => println!("Not Base64: {e}"),
//! Err(e) => println!("Other error: {e}"),
//! Ok(_) => unreachable!("input was bad"),
//! }
//! ```
use Error;
/// All error variants produced by [`encrypt`](crate::encrypt) and
/// [`decrypt`](crate::decrypt).