1 use std::fmt;
2 use tower_layer::Layer;
3 
4 use super::LoadShed;
5 
6 /// A [`Layer`] to wrap services in [`LoadShed`] middleware.
7 ///
8 /// [`Layer`]: crate::Layer
9 #[derive(Clone, Default)]
10 pub struct LoadShedLayer {
11     _p: (),
12 }
13 
14 impl LoadShedLayer {
15     /// Creates a new layer.
new() -> Self16     pub fn new() -> Self {
17         LoadShedLayer { _p: () }
18     }
19 }
20 
21 impl<S> Layer<S> for LoadShedLayer {
22     type Service = LoadShed<S>;
23 
layer(&self, service: S) -> Self::Service24     fn layer(&self, service: S) -> Self::Service {
25         LoadShed::new(service)
26     }
27 }
28 
29 impl fmt::Debug for LoadShedLayer {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result30     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31         f.debug_struct("LoadShedLayer").finish()
32     }
33 }
34