Move the data module into the top-level namespace.

This commit is contained in:
Sergio Benitez 2016-10-25 13:24:07 +02:00
parent f5a5ea3a22
commit 6a8d64f69b
15 changed files with 21 additions and 31 deletions

View File

@ -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),

View File

@ -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;

View File

@ -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 = "<data>")]

View File

@ -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<S, E> = outcome::Outcome<S, (StatusCode, E), Data>;

View File

@ -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;

View File

@ -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 {

View File

@ -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.

View File

@ -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};

View File

@ -1,4 +1,4 @@
use request::Data;
use data::Data;
use outcome::{self, Outcome};
use http::hyper::StatusCode;
use response::{Responder, StatusResponse};

View File

@ -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};

View File

@ -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};

View File

@ -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 {