#[derive(Fail, Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum ErrorKind {
#[fail(display = "Additional data too long. Length in bytes must be less than 2^32")]
AdditionalDataTooLongError,
#[fail(display = "Backend encode error. u32 provided could not be encoded into a Backend")]
BackendEncodeError,
#[fail(display = "Rust backend not yet supported. Please use the C backend")]
BackendUnsupportedError,
#[fail(display = "Base64 decode error. Bytes provided were invalid base64")]
Base64DecodeError,
#[fail(
display = "This is a bug in the argonautica crate and should be unreachable. Please file an issue"
)]
Bug,
#[fail(display = "Hash decode error. Hash provided was invalid")]
HashDecodeError,
#[cfg(test)]
#[fail(display = "Hash encode error. HashRaw provided could not be encoded into a hash")]
HashEncodeError,
#[fail(display = "Hash length too short. Hash length must be at least 4")]
HashLenTooShortError,
#[fail(display = "Hash missing. Attempted to verify without first having provided a hash")]
HashMissingError,
#[fail(display = "Iterations must be greater than 0")]
IterationsTooFewError,
#[fail(display = "Lanes must be greater than 0")]
LanesTooFewError,
#[fail(display = "Lanes must be less than 2^24")]
LanesTooManyError,
#[fail(display = "C code attempted to allocate memory (using malloc) and failed")]
MemoryAllocationError,
#[fail(display = "Memory size invalid. Memory size must be a power of two")]
MemorySizeInvalidError,
#[fail(
display = "Memory size too small. Memory size must be at least 8 times the number of lanes"
)]
MemorySizeTooSmallError,
#[fail(display = "Failed to access OS random number generator")]
OsRngError,
#[fail(
display = "Password immutable error. You attempted to hash or verify with an immutable password and password_clearing set to true, which is not possible because with an immutable password argonautica cannot zero out the password bytes. To prevent this error, either pass Hasher or Verifier a mutable password or set password_clearing to false"
)]
PasswordImmutableError,
#[fail(
display = "Password missing. Attempted to verify without first having provided a password"
)]
PasswordMissingError,
#[fail(display = "Password too long. Length in bytes must be less than 2^32")]
PasswordTooLongError,
#[fail(display = "Password too short. Length in bytes must be greater than 0")]
PasswordTooShortError,
#[fail(display = "Salt too long. Length in bytes must be less than 2^32")]
SaltTooLongError,
#[fail(display = "Salt too short. Length in bytes must be at least 8")]
SaltTooShortError,
#[fail(
display = "Secret key immutable error. You attempted to hash or verify with an immutable secret key and secret_key_clearing set to true, which is not possible because with an immutable secret key argonautica cannot zero out the secret key bytes. To prevent this error, either pass Hasher or Verifier a mutable secret key or set secret_key_clearing to false"
)]
SecretKeyImmutableError,
#[fail(
display = "Secret key missing. Attempted to hash without a secret key without having first opted out of using a secret key"
)]
SecretKeyMissingError,
#[fail(display = "Secret key too long. Length in bytes must be less than 2^32")]
SecretKeyTooLongError,
#[fail(display = "C code reported a \"Threading failure\" error")]
ThreadError,
#[fail(display = "Threads too few. Threads must be greater than 0")]
ThreadsTooFewError,
#[fail(display = "Threads too many. Threads must be less than 2^24")]
ThreadsTooManyError,
#[fail(display = "Utf-8 encode error. Bytes provided could not be encoded into utf-8")]
Utf8EncodeError,
#[fail(display = "Variant encode error. &str provided could not be encoded into a Variant")]
VariantEncodeError,
#[fail(
display = "Version encode error. &str or u32 provided could not be encoded into a Version"
)]
VersionEncodeError,
#[doc(hidden)]
#[fail(display = "__Nonexaustive variant")]
__Nonexhaustive,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_send() {
fn assert_send<T: Send>() {}
assert_send::<ErrorKind>();
}
#[test]
fn test_sync() {
fn assert_sync<T: Sync>() {}
assert_sync::<ErrorKind>();
}
#[cfg(feature = "serde")]
#[test]
fn test_serialize() {
use serde;
fn assert_serialize<T: serde::Serialize>() {}
assert_serialize::<ErrorKind>();
}
#[cfg(feature = "serde")]
#[test]
fn test_deserialize() {
use serde;
fn assert_deserialize<'de, T: serde::Deserialize<'de>>() {}
assert_deserialize::<ErrorKind>();
}
}