1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 00:01:11 +01:00

add helper constructors to Either service

This commit is contained in:
Nikolay Kim 2019-01-16 15:33:10 -08:00
parent b6414d6197
commit 2c8e7c4ae4

View File

@ -51,6 +51,34 @@ pub enum Either<A, 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>
where
A: NewService<Request>,