pub enum Error {
Show 17 variants
CborEncoding(Error<Error>),
CborDecoding(Error<Error>),
Io(Error),
Base64Decoding(DecodeError),
Json(Error),
KeyNotFound(String),
InvalidIssuer {
expected: String,
actual: String,
},
TokenExpired,
TokenNotActive,
InvalidAudience(Vec<String>),
InvalidClaimType,
TagMismatch,
ExpectedCwtTag,
FailedToMac,
UnsupportedValidationType,
UnableToParseToken,
MissingOptionsForMacValidation,
}
Expand description
Errors that can occur during CAT token operations.
This enum represents all the possible errors that can occur when generating, validating, or processing CAT tokens. Each variant provides specific information about what went wrong.
§Examples
use common_access_token::{Cat, CatOptions, CatValidationOptions, CatValidationType};
use std::collections::HashMap;
// Create a CAT instance with a key
let key = hex::decode("403697de87af64611c1d32a05dab0fe1fcb715a86ab435f1ec99192d79569388").unwrap();
let cat = Cat::new(CatOptions {
keys: HashMap::from([("key-1".to_string(), key)]),
expect_cwt_tag: true,
});
// Try to validate an invalid token
let result = cat.validate(
"invalid-token",
CatValidationType::Mac,
&CatValidationOptions {
issuer: "issuer".to_string(),
audience: None,
},
);
// Handle the error
match result {
Ok(_) => println!("Token is valid"),
Err(err) => println!("Error: {}", err),
}
Variants§
CborEncoding(Error<Error>)
CborDecoding(Error<Error>)
Io(Error)
Base64Decoding(DecodeError)
Json(Error)
KeyNotFound(String)
InvalidIssuer
TokenExpired
TokenNotActive
InvalidAudience(Vec<String>)
InvalidClaimType
TagMismatch
ExpectedCwtTag
FailedToMac
UnsupportedValidationType
UnableToParseToken
MissingOptionsForMacValidation
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<DecodeError> for Error
impl From<DecodeError> for Error
Source§fn from(source: DecodeError) -> Self
fn from(source: DecodeError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more