use crate::params::{CollectedArgs, HandlerParam};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct State<S: Clone + Send + Sync + 'static>(pub S);
impl<'a, S> HandlerParam<'a> for State<S>
where
S: Send + Sync + Clone + 'static,
{
fn extract_param(args: &'a CollectedArgs) -> Option<Self> {
let Some(state) = args.get::<State<S>>() else {
return None;
};
Some(State(state.0.clone()))
}
}
#[derive(Clone, Debug)]
pub struct Collected<T>(pub T);
impl<'a, T> HandlerParam<'a> for Collected<T>
where
T: Send + Sync + Clone + 'static,
{
fn extract_param(args: &'a CollectedArgs) -> Option<Self> {
args.get::<Self>().cloned()
}
}