1pub(crate) mod anypoint;
5pub(crate) mod ldap;
6pub(crate) mod os;
7pub mod trace;
8mod utils;
9
10use crate::{UnitGrpcRequest, UnitGrpcResponse, UnitHttpRequest, UnitHttpResponse};
11use std::rc::Rc;
12
13pub trait Backend {
15 fn call(&self, req: UnitHttpRequest) -> UnitHttpResponse;
16}
17
18impl<F> Backend for F
19where
20 F: Fn(UnitHttpRequest) -> UnitHttpResponse,
21{
22 fn call(&self, req: UnitHttpRequest) -> UnitHttpResponse {
23 self(req)
24 }
25}
26
27impl<B: Backend> Backend for Rc<B> {
28 fn call(&self, req: UnitHttpRequest) -> UnitHttpResponse {
29 self.as_ref().call(req)
30 }
31}
32
33impl Backend for UnitHttpResponse {
34 fn call(&self, _: UnitHttpRequest) -> UnitHttpResponse {
35 self.clone()
36 }
37}
38
39pub trait GrpcBackend {
42 fn call(&self, req: UnitGrpcRequest) -> UnitGrpcResponse;
43}
44
45impl<F> GrpcBackend for F
46where
47 F: Fn(UnitGrpcRequest) -> UnitGrpcResponse,
48{
49 fn call(&self, req: UnitGrpcRequest) -> UnitGrpcResponse {
50 self(req)
51 }
52}
53
54impl<B: GrpcBackend> GrpcBackend for Rc<B> {
55 fn call(&self, req: UnitGrpcRequest) -> UnitGrpcResponse {
56 self.as_ref().call(req)
57 }
58}
59
60impl GrpcBackend for UnitGrpcResponse {
61 fn call(&self, _: UnitGrpcRequest) -> UnitGrpcResponse {
62 self.clone()
63 }
64}