diff --git a/codegen/src/decorators/route.rs b/codegen/src/decorators/route.rs index 1a856e8b..476e235f 100644 --- a/codegen/src/decorators/route.rs +++ b/codegen/src/decorators/route.rs @@ -104,7 +104,7 @@ impl RouteGenerateExt for RouteParams { let ty = strip_ty_lifetimes(arg.ty.clone()); Some(quote_stmt!(ecx, let $name: $ty = - match ::rocket::request::FromData::from_data(&_req, _data) { + match ::rocket::data::FromData::from_data(&_req, _data) { ::rocket::outcome::Outcome::Success(d) => d, ::rocket::outcome::Outcome::Forward(d) => return ::rocket::Response::forward(d), diff --git a/contrib/src/json/mod.rs b/contrib/src/json/mod.rs index 72a10adf..f94564a5 100644 --- a/contrib/src/json/mod.rs +++ b/contrib/src/json/mod.rs @@ -5,7 +5,8 @@ use std::ops::{Deref, DerefMut}; use std::io::Read; use rocket::outcome::{Outcome, IntoOutcome}; -use rocket::request::{data, Request, Data, FromData}; +use rocket::request::Request; +use rocket::data::{self, Data, FromData}; use rocket::response::{self, Responder, content}; use rocket::http::StatusCode; use rocket::http::hyper::FreshHyperResponse; diff --git a/examples/raw_upload/src/main.rs b/examples/raw_upload/src/main.rs index 2525b051..38766f61 100644 --- a/examples/raw_upload/src/main.rs +++ b/examples/raw_upload/src/main.rs @@ -5,7 +5,7 @@ extern crate rocket; use std::io; -use rocket::request::Data; +use rocket::Data; use rocket::response::content::Plain; #[post("/upload", format = "text/plain", data = "")] diff --git a/lib/src/request/data/data.rs b/lib/src/data/data.rs similarity index 100% rename from lib/src/request/data/data.rs rename to lib/src/data/data.rs diff --git a/lib/src/request/data/data_stream.rs b/lib/src/data/data_stream.rs similarity index 100% rename from lib/src/request/data/data_stream.rs rename to lib/src/data/data_stream.rs diff --git a/lib/src/request/data/from_data.rs b/lib/src/data/from_data.rs similarity index 98% rename from lib/src/request/data/from_data.rs rename to lib/src/data/from_data.rs index 7258fc52..a14a9221 100644 --- a/lib/src/request/data/from_data.rs +++ b/lib/src/data/from_data.rs @@ -1,7 +1,8 @@ use outcome::{self, IntoOutcome}; use outcome::Outcome::*; use http::StatusCode; -use request::{Request, Data}; +use request::Request; +use data::Data; /// Type alias for the `Outcome` of a `FromData` conversion. pub type Outcome = outcome::Outcome; diff --git a/lib/src/request/data/mod.rs b/lib/src/data/mod.rs similarity index 85% rename from lib/src/request/data/mod.rs rename to lib/src/data/mod.rs index 55c88e8f..0f0288b4 100644 --- a/lib/src/request/data/mod.rs +++ b/lib/src/data/mod.rs @@ -1,4 +1,4 @@ -//! Talk about the data thing. +//! Types and traits for reading and parsing request body data. #[cfg(any(test, feature = "testing"))] pub mod test_data; #[cfg(not(any(test, feature = "testing")))] pub mod data; diff --git a/lib/src/request/data/test_data.rs b/lib/src/data/test_data.rs similarity index 100% rename from lib/src/request/data/test_data.rs rename to lib/src/data/test_data.rs diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 67484d8f..332b149b 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -102,6 +102,7 @@ pub mod request; pub mod response; pub mod outcome; pub mod config; +pub mod data; mod error; mod router; @@ -112,7 +113,8 @@ mod catcher; /// Defines the types for request and error handlers. #[doc(hidden)] pub mod handler { - use request::{Request, Data}; + use data::Data; + use request::Request; use response::Response; use error::Error; @@ -127,12 +129,13 @@ pub mod handler { #[doc(inline)] pub use handler::{Handler, ErrorHandler}; #[doc(inline)] pub use logger::LoggingLevel; #[doc(hidden)] pub use codegen::{StaticRouteInfo, StaticCatchInfo}; +#[doc(inline)] pub use outcome::{Outcome, IntoOutcome}; pub use router::Route; -pub use request::{Request, Data}; +pub use request::Request; +pub use data::Data; pub use error::Error; pub use catcher::Catcher; pub use rocket::Rocket; -pub use outcome::{Outcome, IntoOutcome}; /// Alias to Rocket::ignite(). pub fn ignite() -> Rocket { diff --git a/lib/src/request/form/mod.rs b/lib/src/request/form/mod.rs index 9c2afd1d..8d34f26a 100644 --- a/lib/src/request/form/mod.rs +++ b/lib/src/request/form/mod.rs @@ -28,7 +28,8 @@ use std::fmt::{self, Debug}; use std::io::Read; use http::StatusCode; -use request::{data, Request, FromData, Data}; +use request::Request; +use data::{self, Data, FromData}; use outcome::Outcome::*; // TODO: This works and is safe, but the lifetime appears twice. diff --git a/lib/src/request/mod.rs b/lib/src/request/mod.rs index 085e5f75..56c2bb33 100644 --- a/lib/src/request/mod.rs +++ b/lib/src/request/mod.rs @@ -1,28 +1,11 @@ //! Types and traits for request parsing and handling. -//! -//! # Request and Data -//! -//! The [Request](struct.Request.html) and [Data](struct.Data.html) types -//! contain all of the available information for an incoming request. The -//! `Request` types contains all information _except_ the body, which is -//! contained in the `Data` type. -//! -//! # Code Generation Conversion Traits -//! -//! This module contains the core code generation data conversion traits. These -//! traits are used by Rocket's code generation facilities to automatically -//! derive values from incoming data based on the signature of a request -//! handler. mod request; mod param; mod form; mod from_request; -pub mod data; - pub use self::request::Request; pub use self::from_request::{FromRequest, Outcome}; pub use self::param::{FromParam, FromSegments}; pub use self::form::{Form, FromForm, FromFormValue, FormItems}; -pub use self::data::{Data, FromData}; diff --git a/lib/src/response/response.rs b/lib/src/response/response.rs index d14e1669..14dae683 100644 --- a/lib/src/response/response.rs +++ b/lib/src/response/response.rs @@ -1,4 +1,4 @@ -use request::Data; +use data::Data; use outcome::{self, Outcome}; use http::hyper::StatusCode; use response::{Responder, StatusResponse}; diff --git a/lib/src/rocket.rs b/lib/src/rocket.rs index cdcb8283..ab5cbeea 100644 --- a/lib/src/rocket.rs +++ b/lib/src/rocket.rs @@ -8,7 +8,8 @@ use term_painter::ToStyle; use config; use logger; -use request::{Request, Data, FormItems}; +use request::{Request, FormItems}; +use data::Data; use response::Responder; use router::{Router, Route}; use catcher::{self, Catcher}; diff --git a/lib/src/router/collider.rs b/lib/src/router/collider.rs index 03f327a9..223bad9c 100644 --- a/lib/src/router/collider.rs +++ b/lib/src/router/collider.rs @@ -49,7 +49,8 @@ mod tests { use std::str::FromStr; use router::Collider; - use request::{Request, Data}; + use request::Request; + use data::Data; use response::Response; use router::route::Route; use http::{Method, ContentType}; diff --git a/lib/src/testing.rs b/lib/src/testing.rs index 5e18a7ea..8b48b7a7 100644 --- a/lib/src/testing.rs +++ b/lib/src/testing.rs @@ -43,8 +43,7 @@ use std::io::Cursor; use outcome::Outcome::*; use http::{hyper, Method}; -use request::{Request, Data}; -use Rocket; +use {Rocket, Request, Data}; /// A type for mocking requests for testing Rocket applications. pub struct MockRequest {