actix_web_security/authentication/scheme/bearer/jwt/token/decoder/
mod.rs1use serde::Deserialize;
4
5use crate::authentication::error::error_type::AuthenticationError;
6use crate::authentication::scheme::bearer::jwt::token::Claims;
7
8pub mod rsa_decoder;
9
10pub trait TokenDecoder<T: for<'b> Deserialize<'b> + Claims>: TokenDecoderClone<T> {
13 fn decode_token(&self, token: &str) -> Result<Box<T>, AuthenticationError>;
14}
15
16pub trait TokenDecoderClone<T: for<'b> Deserialize<'b> + Claims>: Send + Sync {
19 fn clone_box(&self) -> Box<dyn TokenDecoder<T>>;
20}
21
22impl<T: for<'b> Deserialize<'b> + Claims, U> TokenDecoderClone<T> for U
23where
24 U: 'static + TokenDecoder<T> + Clone,
25{
26 fn clone_box(&self) -> Box<dyn TokenDecoder<T>> {
27 Box::new(self.clone())
28 }
29}
30
31impl<T: for<'b> Deserialize<'b> + Claims> Clone for Box<dyn TokenDecoder<T>> {
32 fn clone(&self) -> Self {
33 self.clone_box()
34 }
35}