mirror of
https://github.com/fafhrd91/actix-net
synced 2025-03-20 23:05:16 +01:00
add helper constructors to Either service
This commit is contained in:
parent
b6414d6197
commit
2c8e7c4ae4
@ -51,6 +51,34 @@ pub enum Either<A, B> {
|
|||||||
B(B),
|
B(B),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A, B> Either<A, B> {
|
||||||
|
pub fn new_a<Request>(srv: A) -> Self
|
||||||
|
where
|
||||||
|
A: NewService<Request>,
|
||||||
|
B: NewService<
|
||||||
|
Request,
|
||||||
|
Response = A::Response,
|
||||||
|
Error = A::Error,
|
||||||
|
InitError = A::InitError,
|
||||||
|
>,
|
||||||
|
{
|
||||||
|
Either::A(srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_b<Request>(srv: B) -> Self
|
||||||
|
where
|
||||||
|
A: NewService<Request>,
|
||||||
|
B: NewService<
|
||||||
|
Request,
|
||||||
|
Response = A::Response,
|
||||||
|
Error = A::Error,
|
||||||
|
InitError = A::InitError,
|
||||||
|
>,
|
||||||
|
{
|
||||||
|
Either::B(srv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<A, B, Request> NewService<Request> for Either<A, B>
|
impl<A, B, Request> NewService<Request> for Either<A, B>
|
||||||
where
|
where
|
||||||
A: NewService<Request>,
|
A: NewService<Request>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user