use crate::authorities::{AuthDetails, AuthDetailsWrapper};
use rocket::Request;
use std::hash::Hash;
pub trait AttachAuthorities<Type> {
fn attach(&mut self, authorities: Option<impl IntoIterator<Item = Type>>);
}
impl<Type: Eq + Hash + Send + Sync + 'static> AttachAuthorities<Type> for &mut Request<'_> {
fn attach(&mut self, authorities: Option<impl IntoIterator<Item = Type>>) {
let auth_details = authorities
.map(AuthDetails::new)
.map(|details| AuthDetailsWrapper(Some(details)))
.unwrap_or(AuthDetailsWrapper(None));
self.local_cache(|| auth_details);
}
}