1pub mod encodings;
2pub mod pae;
3pub mod tokens;
4pub mod version;
5pub use rand_core;
6pub mod key;
7
8mod sealed {
9 pub trait Sealed {}
10}
11
12#[derive(Debug)]
13#[non_exhaustive]
14pub enum PasetoError {
16 Base64DecodeError,
18 InvalidKey,
20 InvalidToken,
22 CryptoError,
24 PayloadError(std::io::Error),
26}
27
28impl std::error::Error for PasetoError {
29 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
30 match self {
31 PasetoError::PayloadError(x) => Some(x),
32 _ => None,
33 }
34 }
35}
36
37impl std::fmt::Display for PasetoError {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 match self {
40 PasetoError::Base64DecodeError => f.write_str("The token could not be base64 decoded"),
41 PasetoError::InvalidKey => f.write_str("Could not parse the key"),
42 PasetoError::InvalidToken => f.write_str("Could not parse the token"),
43 PasetoError::CryptoError => f.write_str("Token signature could not be validated"),
44 PasetoError::PayloadError(x) => {
45 write!(f, "there was an error with the payload encoding: {x}")
46 }
47 }
48 }
49}