From 3ccaa04575e6d3b07d250e74012cca7d59b4e7c8 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 30 Mar 2018 09:34:03 -0700 Subject: [PATCH] unhide AsyncResponder; remove unused code --- src/handler.rs | 28 ++++++++++++++++++++++++++-- src/server/helpers.rs | 16 ---------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/handler.rs b/src/handler.rs index 32a3d99b2..ff52fc17f 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -97,9 +97,33 @@ impl Responder for Either } } - -#[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> { +/// 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: Sized { fn responder(self) -> Box>; } diff --git a/src/server/helpers.rs b/src/server/helpers.rs index af76b52d5..c50317a9d 100644 --- a/src/server/helpers.rs +++ b/src/server/helpers.rs @@ -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 {