#[non_exhaustive]pub enum Error {
UnsupportedCipher,
InvalidKey,
InvalidKeyLength {
expected: usize,
actual: usize,
},
InvalidPayload,
InvalidMac,
Decrypt,
Encrypt,
Unserialize,
Serialize,
InvalidUtf8,
}Expand description
Errors returned by Encrypter.
The decryption variants mirror the cases of Laravel’s DecryptException, so a tampered
payload (InvalidMac, Decrypt) can be told
apart from a malformed one (InvalidPayload). The messages are
Laravel’s.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnsupportedCipher
The cipher name is not one of aes-128-cbc, aes-256-cbc, aes-128-gcm or
aes-256-gcm.
InvalidKey
The key is empty or is a malformed base64: value.
InvalidKeyLength
The key does not have the length the cipher requires.
Fields
InvalidPayload
The payload is not a valid Laravel payload (bad base64 or JSON, missing fields, wrong IV length).
InvalidMac
The HMAC of a CBC payload does not match (tampered payload or wrong key).
Decrypt
The data could not be decrypted (bad GCM tag, wrong key, bad padding, or a tag where the cipher does not use one).
Encrypt
The data could not be encrypted.
Unserialize
The decrypted plaintext is not valid PHP serialize() output, or uses a feature this
crate does not decode.
Serialize
The value cannot be PHP-serialized (see Value::Object).
InvalidUtf8
The decrypted plaintext is not valid UTF-8; use
Encrypter::decrypt_bytes.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()