mysten_network/callback/
layer.rs1use super::{Callback, MakeCallbackHandler};
5use tower::Layer;
6
7#[derive(Debug, Copy, Clone)]
14pub struct CallbackLayer<M> {
15 pub(crate) make_handler: M,
16}
17
18impl<M> CallbackLayer<M> {
19 pub fn new(make_handler: M) -> Self
21 where
22 M: MakeCallbackHandler,
23 {
24 Self { make_handler }
25 }
26}
27
28impl<S, M> Layer<S> for CallbackLayer<M>
29where
30 M: Clone,
31{
32 type Service = Callback<S, M>;
33
34 fn layer(&self, inner: S) -> Self::Service {
35 Callback {
36 inner,
37 make_callback_handler: self.make_handler.clone(),
38 }
39 }
40}