actix_web_security/user_details/
mod.rs

1//! The user_details module provides all user retrieval related functionality that is required for the authentication process.
2
3use downcast_rs::impl_downcast;
4use downcast_rs::Downcast;
5
6pub mod attachment;
7pub mod request_extension;
8
9/// Marker trait for a user object to put into the request context.
10pub trait UserDetails: Downcast + UserDetailsClone {}
11impl_downcast!(UserDetails);
12
13/// A user details object must be cloneable.
14/// Therefore it has to implement the `UserDetailsClone` trait to be cloneable as a boxed object.
15pub trait UserDetailsClone {
16    fn clone_box(&self) -> Box<dyn UserDetails>;
17}
18
19impl<U> UserDetailsClone for U
20where
21    U: 'static + UserDetails + Clone,
22{
23    fn clone_box(&self) -> Box<dyn UserDetails> {
24        Box::new(self.clone())
25    }
26}
27
28impl Clone for Box<dyn UserDetails> {
29    fn clone(&self) -> Self {
30        self.clone_box()
31    }
32}