diff --git a/codegen/src/decorators/derive_form.rs b/codegen/src/decorators/derive_form.rs index b3f093f7..a3f1df84 100644 --- a/codegen/src/decorators/derive_form.rs +++ b/codegen/src/decorators/derive_form.rs @@ -68,7 +68,7 @@ pub fn from_form_derive(ecx: &mut ExtCtxt, span: Span, meta_item: &MetaItem, span: span, attributes: Vec::new(), path: ty::Path { - path: vec!["rocket", "form", "FromForm"], + path: vec!["rocket", "request", "FromForm"], lifetime: lifetime_var, params: vec![], global: true, @@ -169,7 +169,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct let id_str = ident_string.as_str(); arms.push(quote_tokens!(cx, $id_str => { - $ident = match ::rocket::form::FromFormValue::from_form_value(v) { + $ident = match ::rocket::request::FromFormValue::from_form_value(v) { Ok(v) => Some(v), Err(e) => { println!("\tError parsing form val '{}': {:?}", $id_str, e); @@ -183,7 +183,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct // The actual match statement. Iterate through all of the fields in the form // and use the $arms generated above. stmts.push(quote_stmt!(cx, - for (k, v) in ::rocket::form::FormItems($arg) { + for (k, v) in ::rocket::request::FormItems($arg) { match k { $arms _ => { @@ -205,7 +205,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct failure_conditions.push(quote_tokens!(cx, if $ident.is_none() && - <$ty as ::rocket::form::FromFormValue>::default().is_none() { + <$ty as ::rocket::request::FromFormValue>::default().is_none() { println!("\t'{}' did not parse.", stringify!($ident)); true } else { false } @@ -218,7 +218,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct for &(ref ident, ty) in &fields_and_types { result_fields.push(quote_tokens!(cx, $ident: $ident.unwrap_or_else(|| - <$ty as ::rocket::form::FromFormValue>::default().unwrap() + <$ty as ::rocket::request::FromFormValue>::default().unwrap() ), )); } diff --git a/codegen/src/decorators/route.rs b/codegen/src/decorators/route.rs index 637f9080..2c3f956c 100644 --- a/codegen/src/decorators/route.rs +++ b/codegen/src/decorators/route.rs @@ -82,7 +82,7 @@ impl RouteGenerateExt for RouteParams { let ty = strip_ty_lifetimes(arg.ty.clone()); Some(quote_stmt!(ecx, let $name: $ty = - match ::rocket::form::FromForm::from_form_string($form_string) { + match ::rocket::request::FromForm::from_form_string($form_string) { Ok(v) => v, Err(_) => return ::rocket::Response::forward() }; diff --git a/codegen/tests/run-pass/derive_form.rs b/codegen/tests/run-pass/derive_form.rs index f2d0434a..7fdf79b2 100644 --- a/codegen/tests/run-pass/derive_form.rs +++ b/codegen/tests/run-pass/derive_form.rs @@ -3,7 +3,7 @@ extern crate rocket; -use rocket::form::FromForm; +use rocket::request::{FromForm, FromFormValue}; #[derive(Debug, PartialEq, FromForm)] struct TodoTask { @@ -17,8 +17,6 @@ enum FormOption { A, B, C } -use rocket::form::FromFormValue; - impl<'v> FromFormValue<'v> for FormOption { type Error = &'v str; diff --git a/examples/extended_validation/src/main.rs b/examples/extended_validation/src/main.rs index 15c49dc3..c9d3d192 100644 --- a/examples/extended_validation/src/main.rs +++ b/examples/extended_validation/src/main.rs @@ -6,7 +6,7 @@ extern crate rocket; mod files; use rocket::response::Redirect; -use rocket::form::FromFormValue; +use rocket::request::FromFormValue; #[derive(Debug)] struct StrongPassword<'r>(&'r str); diff --git a/examples/form_kitchen_sink/src/main.rs b/examples/form_kitchen_sink/src/main.rs index 1c362b02..996846e5 100644 --- a/examples/form_kitchen_sink/src/main.rs +++ b/examples/form_kitchen_sink/src/main.rs @@ -3,9 +3,8 @@ extern crate rocket; -use rocket::Request; +use rocket::request::{Request, FromFormValue}; use rocket::response::NamedFile; -use rocket::form::FromFormValue; use std::io; // TODO: Make deriving `FromForm` for this enum possible. diff --git a/examples/handlebars_templates/src/main.rs b/examples/handlebars_templates/src/main.rs index d065a229..77988baf 100644 --- a/examples/handlebars_templates/src/main.rs +++ b/examples/handlebars_templates/src/main.rs @@ -6,7 +6,7 @@ extern crate rocket; extern crate serde_json; #[macro_use] extern crate serde_derive; -use rocket::{Request, Error}; +use rocket::{Request}; use rocket::response::Redirect; use rocket_contrib::Template; diff --git a/examples/json/src/main.rs b/examples/json/src/main.rs index acf18b9b..2b017bf5 100644 --- a/examples/json/src/main.rs +++ b/examples/json/src/main.rs @@ -7,7 +7,6 @@ extern crate serde_json; #[macro_use] extern crate rocket_contrib; #[macro_use] extern crate serde_derive; -use rocket::{Request, Error}; use rocket_contrib::JSON; use std::collections::HashMap; use std::sync::Mutex; diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 19346ad6..ac07f0b9 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -70,9 +70,9 @@ extern crate toml; #[doc(hidden)] #[macro_use] pub mod logger; #[doc(hidden)] pub mod http; -pub mod form; pub mod request; pub mod response; +pub mod outcome; mod error; mod router; diff --git a/lib/src/response/outcome.rs b/lib/src/outcome.rs similarity index 100% rename from lib/src/response/outcome.rs rename to lib/src/outcome.rs diff --git a/lib/src/request/data.rs b/lib/src/request/data.rs deleted file mode 100644 index 536ca2bf..00000000 --- a/lib/src/request/data.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::io::Read; - -pub struct Data { - stream: Box -} - -pub trait FromData { - fn from_data(data: Data) -> Outcome { } -} diff --git a/lib/src/form.rs b/lib/src/request/form.rs similarity index 98% rename from lib/src/form.rs rename to lib/src/request/form.rs index e54f596d..66140bde 100644 --- a/lib/src/form.rs +++ b/lib/src/request/form.rs @@ -71,7 +71,7 @@ impl<'f> FromForm<'f> for &'f str { /// might define a new type and implement `FromFormValue` as follows: /// /// ```rust -/// use rocket::form::FromFormValue; +/// use rocket::request::FromFormValue; /// use rocket::Error; /// /// struct AdultAge(usize); @@ -210,7 +210,7 @@ impl<'v, T: FromFormValue<'v>> FromFormValue<'v> for Result { /// `FormItems` can be used directly as an iterator: /// /// ```rust -/// use rocket::form::FormItems; +/// use rocket::request::FormItems; /// /// // prints "greeting = hello" then "username = jake" /// let form_string = "greeting=hello&username=jake"; @@ -222,7 +222,7 @@ impl<'v, T: FromFormValue<'v>> FromFormValue<'v> for Result { /// This is the same example as above, but the iterator is used explicitly. /// /// ```rust -/// use rocket::form::FormItems; +/// use rocket::request::FormItems; /// /// let form_string = "greeting=hello&username=jake"; /// let mut items = FormItems(form_string); diff --git a/lib/src/request/mod.rs b/lib/src/request/mod.rs index b5bae776..9a6f49eb 100644 --- a/lib/src/request/mod.rs +++ b/lib/src/request/mod.rs @@ -2,8 +2,10 @@ mod request; mod param; +mod form; mod from_request; pub use self::request::Request; pub use self::from_request::FromRequest; pub use self::param::{FromParam, FromSegments}; +pub use self::form::{FromForm, FromFormValue, FormItems}; diff --git a/lib/src/response/mod.rs b/lib/src/response/mod.rs index 34df4727..4374724d 100644 --- a/lib/src/response/mod.rs +++ b/lib/src/response/mod.rs @@ -2,7 +2,6 @@ mod empty; mod responder; mod redirect; mod with_status; -mod outcome; mod flash; mod named_file; mod stream; @@ -13,11 +12,11 @@ pub use self::responder::Responder; pub use self::empty::{Empty, Forward}; pub use self::redirect::Redirect; pub use self::with_status::StatusResponse; -pub use self::outcome::{Outcome, ResponseOutcome}; pub use self::flash::Flash; pub use self::named_file::NamedFile; pub use self::stream::Stream; pub use self::data::Content; +pub use outcome::{Outcome, ResponseOutcome}; use std::ops::{Deref, DerefMut}; use http::hyper::StatusCode; diff --git a/lib/src/rocket.rs b/lib/src/rocket.rs index e73e5ac0..f64cb78c 100644 --- a/lib/src/rocket.rs +++ b/lib/src/rocket.rs @@ -8,11 +8,10 @@ use term_painter::ToStyle; use config; use logger; -use request::Request; +use request::{Request, FormItems}; use router::{Router, Route}; use catcher::{self, Catcher}; -use response::Outcome; -use form::FormItems; +use outcome::Outcome; use error::Error; use http::Method;