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:
parent
b6414d6197
commit
2c8e7c4ae4
@ -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>,
|
||||
|
Loading…
Reference in New Issue
Block a user