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