proto_tower_http_1/client/
make_layer.rs1use crate::client::layer::ProtoHttp1ClientLayer;
2use crate::client::ProtoHttp1ClientConfig;
3use std::marker::PhantomData;
4use tokio::io::{ReadHalf, SimplexStream, WriteHalf};
5use tower::{Layer, Service};
6
7pub struct ProtoHttp1ClientMakeLayer<Svc>
11where
12 Svc: Service<(ReadHalf<SimplexStream>, WriteHalf<SimplexStream>), Response = ()> + Send + Clone,
13{
14 config: ProtoHttp1ClientConfig,
15 phantom_service: PhantomData<Svc>,
16}
17
18impl<Svc> ProtoHttp1ClientMakeLayer<Svc>
19where
20 Svc: Service<(ReadHalf<SimplexStream>, WriteHalf<SimplexStream>), Response = ()> + Send + Clone,
21{
22 pub fn new(config: ProtoHttp1ClientConfig) -> Self {
24 ProtoHttp1ClientMakeLayer {
25 phantom_service: PhantomData,
26 config,
27 }
28 }
29}
30
31impl<Svc> Layer<Svc> for ProtoHttp1ClientMakeLayer<Svc>
32where
33 Svc: Service<(ReadHalf<SimplexStream>, WriteHalf<SimplexStream>), Response = ()> + Send + Clone,
34{
35 type Service = ProtoHttp1ClientLayer<Svc>;
36
37 fn layer(&self, inner: Svc) -> Self::Service {
38 ProtoHttp1ClientLayer::new(self.config.clone(), inner)
39 }
40}