1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-08-02 18:55:05 +00:00

unhide AsyncResponder; remove unused code

This commit is contained in:
Nikolay Kim 2018-03-30 09:34:03 -07:00
parent d80b84c915
commit 3ccaa04575
2 changed files with 26 additions and 18 deletions

View file

@ -97,9 +97,33 @@ impl<A, B> Responder for Either<A, B>
}
}
#[doc(hidden)]
/// Convenience trait that convert `Future` object into `Boxed` future
///
/// For example loading json from request's body is async operation.
///
/// ```rust
/// # extern crate actix_web;
/// # extern crate futures;
/// # #[macro_use] extern crate serde_derive;
/// use actix_web::*;
/// use futures::future::Future;
///
/// #[derive(Deserialize, Debug)]
/// struct MyObj {
/// name: String,
/// }
///
/// fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
/// req.json() // <- get JsonBody future
/// .from_err()
/// .and_then(|val: MyObj| { // <- deserialized value
/// Ok(httpcodes::HttpOk.into())
/// })
/// // Construct boxed future by using `AsyncResponder::responder()` method
/// .responder()
/// }
/// # fn main() {}
/// ```
pub trait AsyncResponder<I, E>: Sized {
fn responder(self) -> Box<Future<Item=I, Error=E>>;
}

View file

@ -1,7 +1,6 @@
use std::{mem, ptr, slice};
use std::cell::RefCell;
use std::rc::Rc;
use std::ops::{Deref, DerefMut};
use std::collections::VecDeque;
use bytes::{BufMut, BytesMut};
use http::Version;
@ -50,21 +49,6 @@ impl Drop for SharedHttpInnerMessage {
}
}
impl Deref for SharedHttpInnerMessage {
type Target = HttpInnerMessage;
fn deref(&self) -> &HttpInnerMessage {
self.get_ref()
}
}
impl DerefMut for SharedHttpInnerMessage {
fn deref_mut(&mut self) -> &mut HttpInnerMessage {
self.get_mut()
}
}
impl Clone for SharedHttpInnerMessage {
fn clone(&self) -> SharedHttpInnerMessage {