trait_net/retry/
stream.rs1use std::future::Future;
2
3pub trait Stream<Request> {
4 type Response;
5 type Function: Future<Output = Self::Response>;
6
7 fn next(&self, request: Request) -> Self::Function;
8}
9
10impl<T, Function> Stream<()> for T
11where
12 T: Fn() -> Function,
13 Function: Future,
14{
15 type Response = Function::Output;
16 type Function = Function;
17
18 fn next(&self, _: ()) -> Self::Function {
19 (self)()
20 }
21}
22
23impl<T, Function, Arg1> Stream<(Arg1,)> for T
24where
25 T: Fn(Arg1) -> Function,
26 Function: Future,
27{
28 type Response = Function::Output;
29 type Function = Function;
30
31 fn next(&self, request: (Arg1,)) -> Self::Function {
32 (self)(request.0)
33 }
34}
35
36impl<T, Function, Arg1, Arg2> Stream<(Arg1, Arg2)> for T
37where
38 T: Fn(Arg1, Arg2) -> Function,
39 Function: Future,
40{
41 type Response = Function::Output;
42 type Function = Function;
43
44 fn next(&self, request: (Arg1, Arg2)) -> Self::Function {
45 (self)(request.0, request.1)
46 }
47}
48
49impl<T, Function, Arg1, Arg2, Arg3> Stream<(Arg1, Arg2, Arg3)> for T
50where
51 T: Fn(Arg1, Arg2, Arg3) -> Function,
52 Function: Future,
53{
54 type Response = Function::Output;
55 type Function = Function;
56
57 fn next(&self, request: (Arg1, Arg2, Arg3)) -> Self::Function {
58 (self)(request.0, request.1, request.2)
59 }
60}