1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-21 21:25:36 +02:00

fix drain support for actor; make pattern more reusable

This commit is contained in:
Nikolay Kim
2018-01-02 23:43:17 -08:00
parent 9e6d090fd0
commit 70ea43b3c0
6 changed files with 82 additions and 30 deletions

View File

@@ -144,6 +144,7 @@ impl<T: Responder, E: Into<Error>> Responder for Result<T, E>
}
impl<E: Into<Error>> From<Result<Reply, E>> for Reply {
#[inline]
fn from(res: Result<Reply, E>) -> Self {
match res {
Ok(val) => val,
@@ -152,6 +153,23 @@ impl<E: Into<Error>> From<Result<Reply, E>> for Reply {
}
}
impl<E: Into<Error>> From<Result<HttpResponse, E>> for Reply {
#[inline]
fn from(res: Result<HttpResponse, E>) -> Self {
match res {
Ok(val) => Reply(ReplyItem::Message(val)),
Err(err) => Reply(ReplyItem::Message(err.into().into())),
}
}
}
impl From<Box<Future<Item=HttpResponse, Error=Error>>> for Reply {
#[inline]
fn from(fut: Box<Future<Item=HttpResponse, Error=Error>>) -> Reply {
Reply(ReplyItem::Future(fut))
}
}
impl<I, E> Responder for Box<Future<Item=I, Error=E>>
where I: Responder + 'static,
E: Into<Error> + 'static