use super::Limit;
use tower_async_layer::Layer;
#[derive(Debug)]
pub struct LimitLayer<P> {
policy: P,
}
impl<P> LimitLayer<P> {
pub fn new(policy: P) -> Self {
LimitLayer { policy }
}
}
impl<T, P> Layer<T> for LimitLayer<P>
where
P: Clone,
{
type Service = Limit<T, P>;
fn layer(&self, service: T) -> Self::Service {
let policy = self.policy.clone();
Limit::new(service, policy)
}
}