From e8b3c303b75d068d5f5b73788babcd29bd98ab60 Mon Sep 17 00:00:00 2001 From: Douman Date: Thu, 12 Jul 2018 23:53:39 +0300 Subject: [PATCH] Move serde_urlencoded to src/ --- Cargo.toml | 5 +- serde_urlencoded/Cargo.toml | 25 --- serde_urlencoded/LICENSE-APACHE | 176 ------------------ serde_urlencoded/LICENSE-MIT | 25 --- serde_urlencoded/README.md | 56 ------ serde_urlencoded/src/lib.rs | 17 -- serde_urlencoded/tests/test_deserialize.rs | 62 ------ serde_urlencoded/tests/test_serialize.rs | 50 ----- src/lib.rs | 2 +- .../src => src/serde_urlencoded}/de.rs | 5 +- src/serde_urlencoded/mod.rs | 114 ++++++++++++ .../src => src/serde_urlencoded}/ser/key.rs | 4 +- .../src => src/serde_urlencoded}/ser/mod.rs | 2 +- .../src => src/serde_urlencoded}/ser/pair.rs | 8 +- .../src => src/serde_urlencoded}/ser/part.rs | 37 ++-- .../src => src/serde_urlencoded}/ser/value.rs | 4 +- 16 files changed, 150 insertions(+), 442 deletions(-) delete mode 100644 serde_urlencoded/Cargo.toml delete mode 100644 serde_urlencoded/LICENSE-APACHE delete mode 100644 serde_urlencoded/LICENSE-MIT delete mode 100644 serde_urlencoded/README.md delete mode 100644 serde_urlencoded/src/lib.rs delete mode 100644 serde_urlencoded/tests/test_deserialize.rs delete mode 100644 serde_urlencoded/tests/test_serialize.rs rename {serde_urlencoded/src => src/serde_urlencoded}/de.rs (99%) create mode 100644 src/serde_urlencoded/mod.rs rename {serde_urlencoded/src => src/serde_urlencoded}/ser/key.rs (96%) rename {serde_urlencoded/src => src/serde_urlencoded}/ser/mod.rs (99%) rename {serde_urlencoded/src => src/serde_urlencoded}/ser/pair.rs (97%) rename {serde_urlencoded/src => src/serde_urlencoded}/ser/part.rs (85%) rename {serde_urlencoded/src => src/serde_urlencoded}/ser/value.rs (95%) diff --git a/Cargo.toml b/Cargo.toml index 422bf105c..4b8054ca4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,6 @@ rand = "0.5" regex = "1.0" serde = "1.0" serde_json = "1.0" -serde_urlencoded = { path = "./serde_urlencoded/" } sha1 = "0.6" smallvec = "0.6" time = "0.1" @@ -104,6 +103,10 @@ tokio-tls = { version="0.1", optional = true } openssl = { version="0.10", optional = true } tokio-openssl = { version="0.2", optional = true } +# forked url_encoded +itoa = "0.4" +dtoa = "0.4" + [dev-dependencies] env_logger = "0.5" serde_derive = "1.0" diff --git a/serde_urlencoded/Cargo.toml b/serde_urlencoded/Cargo.toml deleted file mode 100644 index cc66891be..000000000 --- a/serde_urlencoded/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "serde_urlencoded" -version = "0.5.2" -authors = ["Anthony Ramine "] -license = "MIT/Apache-2.0" -repository = "https://github.com/nox/serde_urlencoded" -documentation = "https://docs.rs/serde_urlencoded" -description = "`x-www-form-urlencoded` meets Serde" -categories = ["encoding", "web-programming"] -keywords = ["serde", "serialization", "urlencoded"] - -[badges] -travis-ci = {repository = "nox/serde_urlencoded"} - -[lib] -test = false - -[dependencies] -dtoa = "0.4.0" -itoa = "0.4.0" -serde = "1.0.0" -url = "1.0.0" - -[dev-dependencies] -serde_derive = "1.0" diff --git a/serde_urlencoded/LICENSE-APACHE b/serde_urlencoded/LICENSE-APACHE deleted file mode 100644 index 1b5ec8b78..000000000 --- a/serde_urlencoded/LICENSE-APACHE +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS diff --git a/serde_urlencoded/LICENSE-MIT b/serde_urlencoded/LICENSE-MIT deleted file mode 100644 index 39f6303ad..000000000 --- a/serde_urlencoded/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2016 Anthony Ramine - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/serde_urlencoded/README.md b/serde_urlencoded/README.md deleted file mode 100644 index ba74c2ded..000000000 --- a/serde_urlencoded/README.md +++ /dev/null @@ -1,56 +0,0 @@ -`x-www-form-urlencoded` meets Serde -=================================== - -## Fork Note - -This is a local fork for actix-web due to the original repo being unmaintained. - -## README - -This crate is a Rust library for serialising to and deserialising from -the [`application/x-www-form-urlencoded`][urlencoded] format. It is built -upon [Serde], a high performance generic serialization framework and [rust-url], -a URL parser for Rust. - -[rust-url]: https://github.com/servo/rust-url -[Serde]: https://github.com/serde-rs/serde -[urlencoded]: https://url.spec.whatwg.org/#application/x-www-form-urlencoded - -Installation -============ - -This crate works with Cargo and can be found on -[crates.io] with a `Cargo.toml` like: - -```toml -[dependencies] -serde_urlencoded = "0.5.1" -``` - -[crates.io]: https://crates.io/crates/serde_urlencoded - -## Getting help - -Serde developers live in the #serde channel on -[`irc.mozilla.org`](https://wiki.mozilla.org/IRC) and most rust-url developers -live in the #servo one. The #rust channel is also a good resource with generally -faster response time but less specific knowledge about Serde, rust-url or this -crate. If IRC is not your thing, we are happy to respond to [GitHub -issues](https://github.com/nox/serde_urlencoded/issues/new) as well. - -## License - -serde_urlencoded is licensed under either of - - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or - http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or - http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in serde_urlencoded by you, as defined in the Apache-2.0 license, -shall be dual licensed as above, without any additional terms or conditions. diff --git a/serde_urlencoded/src/lib.rs b/serde_urlencoded/src/lib.rs deleted file mode 100644 index bf7ad591f..000000000 --- a/serde_urlencoded/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! `x-www-form-urlencoded` meets Serde - -#![warn(unused_extern_crates)] - -extern crate itoa; -extern crate dtoa; -#[macro_use] -extern crate serde; -extern crate url; - -pub mod de; -pub mod ser; - -#[doc(inline)] -pub use de::{Deserializer, from_bytes, from_reader, from_str}; -#[doc(inline)] -pub use ser::{Serializer, to_string}; diff --git a/serde_urlencoded/tests/test_deserialize.rs b/serde_urlencoded/tests/test_deserialize.rs deleted file mode 100644 index ee19374ca..000000000 --- a/serde_urlencoded/tests/test_deserialize.rs +++ /dev/null @@ -1,62 +0,0 @@ -extern crate serde_urlencoded; -#[macro_use] -extern crate serde_derive; - -#[test] -fn deserialize_bytes() { - let result = vec![("first".to_owned(), 23), ("last".to_owned(), 42)]; - - assert_eq!(serde_urlencoded::from_bytes(b"first=23&last=42"), - Ok(result)); -} - -#[test] -fn deserialize_str() { - let result = vec![("first".to_owned(), 23), ("last".to_owned(), 42)]; - - assert_eq!(serde_urlencoded::from_str("first=23&last=42"), - Ok(result)); -} - -#[test] -fn deserialize_reader() { - let result = vec![("first".to_owned(), 23), ("last".to_owned(), 42)]; - - assert_eq!(serde_urlencoded::from_reader(b"first=23&last=42" as &[_]), - Ok(result)); -} - -#[test] -fn deserialize_option() { - let result = vec![ - ("first".to_owned(), Some(23)), - ("last".to_owned(), Some(42)), - ]; - assert_eq!(serde_urlencoded::from_str("first=23&last=42"), Ok(result)); -} - -#[test] -fn deserialize_unit() { - assert_eq!(serde_urlencoded::from_str(""), Ok(())); - assert_eq!(serde_urlencoded::from_str("&"), Ok(())); - assert_eq!(serde_urlencoded::from_str("&&"), Ok(())); - assert!(serde_urlencoded::from_str::<()>("first=23").is_err()); -} - -#[derive(Deserialize, Debug, PartialEq, Eq)] -enum X { - A, - B, - C, -} - -#[test] -fn deserialize_unit_enum() { - let result = vec![ - ("one".to_owned(), X::A), - ("two".to_owned(), X::B), - ("three".to_owned(), X::C) - ]; - - assert_eq!(serde_urlencoded::from_str("one=A&two=B&three=C"), Ok(result)); -} diff --git a/serde_urlencoded/tests/test_serialize.rs b/serde_urlencoded/tests/test_serialize.rs deleted file mode 100644 index 3905ce6b8..000000000 --- a/serde_urlencoded/tests/test_serialize.rs +++ /dev/null @@ -1,50 +0,0 @@ -extern crate serde_urlencoded; -#[macro_use] -extern crate serde_derive; - -#[test] -fn serialize_option_map_int() { - let params = &[("first", Some(23)), ("middle", None), ("last", Some(42))]; - - assert_eq!(serde_urlencoded::to_string(params), - Ok("first=23&last=42".to_owned())); -} - -#[test] -fn serialize_option_map_string() { - let params = - &[("first", Some("hello")), ("middle", None), ("last", Some("world"))]; - - assert_eq!(serde_urlencoded::to_string(params), - Ok("first=hello&last=world".to_owned())); -} - -#[test] -fn serialize_option_map_bool() { - let params = &[("one", Some(true)), ("two", Some(false))]; - - assert_eq!(serde_urlencoded::to_string(params), - Ok("one=true&two=false".to_owned())); -} - -#[test] -fn serialize_map_bool() { - let params = &[("one", true), ("two", false)]; - - assert_eq!(serde_urlencoded::to_string(params), - Ok("one=true&two=false".to_owned())); -} - -#[derive(Serialize)] -enum X { - A, - B, - C, -} - -#[test] -fn serialize_unit_enum() { - let params = &[("one", X::A), ("two", X::B), ("three", X::C)]; - assert_eq!(serde_urlencoded::to_string(params), - Ok("one=A&two=B&three=C".to_owned())); -} diff --git a/src/lib.rs b/src/lib.rs index a301227b3..c55fe0256 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,7 +133,6 @@ extern crate num_cpus; #[macro_use] extern crate percent_encoding; extern crate serde_json; -extern crate serde_urlencoded; extern crate smallvec; #[macro_use] extern crate actix as actix_inner; @@ -152,6 +151,7 @@ extern crate openssl; #[cfg(feature = "openssl")] extern crate tokio_openssl; +mod serde_urlencoded; mod application; mod body; mod context; diff --git a/serde_urlencoded/src/de.rs b/src/serde_urlencoded/de.rs similarity index 99% rename from serde_urlencoded/src/de.rs rename to src/serde_urlencoded/de.rs index 4c3fe1b93..affbfb37e 100644 --- a/serde_urlencoded/src/de.rs +++ b/src/serde_urlencoded/de.rs @@ -14,7 +14,7 @@ pub use serde::de::value::Error; /// Deserializes a `application/x-wwww-url-encoded` value from a `&[u8]`. /// -/// ``` +/// ```ignore /// let meal = vec![ /// ("bread".to_owned(), "baguette".to_owned()), /// ("cheese".to_owned(), "comté".to_owned()), @@ -35,7 +35,7 @@ pub fn from_bytes<'de, T>(input: &'de [u8]) -> Result /// Deserializes a `application/x-wwww-url-encoded` value from a `&str`. /// -/// ``` +/// ```ignore /// let meal = vec![ /// ("bread".to_owned(), "baguette".to_owned()), /// ("cheese".to_owned(), "comté".to_owned()), @@ -54,6 +54,7 @@ pub fn from_str<'de, T>(input: &'de str) -> Result from_bytes(input.as_bytes()) } +#[allow(dead_code)] /// Convenience function that reads all bytes from `reader` and deserializes /// them with `from_bytes`. pub fn from_reader(mut reader: R) -> Result diff --git a/src/serde_urlencoded/mod.rs b/src/serde_urlencoded/mod.rs new file mode 100644 index 000000000..6ee62c2a9 --- /dev/null +++ b/src/serde_urlencoded/mod.rs @@ -0,0 +1,114 @@ +//! `x-www-form-urlencoded` meets Serde + +extern crate itoa; +extern crate dtoa; + +pub mod de; +pub mod ser; + +#[doc(inline)] +pub use self::de::{Deserializer, from_bytes, from_reader, from_str}; +#[doc(inline)] +pub use self::ser::{Serializer, to_string}; + +#[cfg(test)] +mod tests { + #[test] + fn deserialize_bytes() { + let result = vec![("first".to_owned(), 23), ("last".to_owned(), 42)]; + + assert_eq!(super::from_bytes(b"first=23&last=42"), + Ok(result)); + } + + #[test] + fn deserialize_str() { + let result = vec![("first".to_owned(), 23), ("last".to_owned(), 42)]; + + assert_eq!(super::from_str("first=23&last=42"), + Ok(result)); + } + + #[test] + fn deserialize_reader() { + let result = vec![("first".to_owned(), 23), ("last".to_owned(), 42)]; + + assert_eq!(super::from_reader(b"first=23&last=42" as &[_]), + Ok(result)); + } + + #[test] + fn deserialize_option() { + let result = vec![ + ("first".to_owned(), Some(23)), + ("last".to_owned(), Some(42)), + ]; + assert_eq!(super::from_str("first=23&last=42"), Ok(result)); + } + + #[test] + fn deserialize_unit() { + assert_eq!(super::from_str(""), Ok(())); + assert_eq!(super::from_str("&"), Ok(())); + assert_eq!(super::from_str("&&"), Ok(())); + assert!(super::from_str::<()>("first=23").is_err()); + } + + #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] + enum X { + A, + B, + C, + } + + #[test] + fn deserialize_unit_enum() { + let result = vec![ + ("one".to_owned(), X::A), + ("two".to_owned(), X::B), + ("three".to_owned(), X::C) + ]; + + assert_eq!(super::from_str("one=A&two=B&three=C"), Ok(result)); + } + + #[test] + fn serialize_option_map_int() { + let params = &[("first", Some(23)), ("middle", None), ("last", Some(42))]; + + assert_eq!(super::to_string(params), + Ok("first=23&last=42".to_owned())); + } + + #[test] + fn serialize_option_map_string() { + let params = + &[("first", Some("hello")), ("middle", None), ("last", Some("world"))]; + + assert_eq!(super::to_string(params), + Ok("first=hello&last=world".to_owned())); + } + + #[test] + fn serialize_option_map_bool() { + let params = &[("one", Some(true)), ("two", Some(false))]; + + assert_eq!(super::to_string(params), + Ok("one=true&two=false".to_owned())); + } + + #[test] + fn serialize_map_bool() { + let params = &[("one", true), ("two", false)]; + + assert_eq!(super::to_string(params), + Ok("one=true&two=false".to_owned())); + } + + #[test] + fn serialize_unit_enum() { + let params = &[("one", X::A), ("two", X::B), ("three", X::C)]; + assert_eq!(super::to_string(params), + Ok("one=A&two=B&three=C".to_owned())); + } +} diff --git a/serde_urlencoded/src/ser/key.rs b/src/serde_urlencoded/ser/key.rs similarity index 96% rename from serde_urlencoded/src/ser/key.rs rename to src/serde_urlencoded/ser/key.rs index 6cbbff429..2d138f18e 100644 --- a/serde_urlencoded/src/ser/key.rs +++ b/src/serde_urlencoded/ser/key.rs @@ -1,5 +1,5 @@ -use ser::Error; -use ser::part::Sink; +use super::super::ser::Error; +use super::super::ser::part::Sink; use serde::Serialize; use std::borrow::Cow; use std::ops::Deref; diff --git a/serde_urlencoded/src/ser/mod.rs b/src/serde_urlencoded/ser/mod.rs similarity index 99% rename from serde_urlencoded/src/ser/mod.rs rename to src/serde_urlencoded/ser/mod.rs index 7d6bab82c..f8d5e13e6 100644 --- a/serde_urlencoded/src/ser/mod.rs +++ b/src/serde_urlencoded/ser/mod.rs @@ -15,7 +15,7 @@ use url::form_urlencoded::Target as UrlEncodedTarget; /// Serializes a value into a `application/x-wwww-url-encoded` `String` buffer. /// -/// ``` +/// ```ignore /// let meal = &[ /// ("bread", "baguette"), /// ("cheese", "comté"), diff --git a/serde_urlencoded/src/ser/pair.rs b/src/serde_urlencoded/ser/pair.rs similarity index 97% rename from serde_urlencoded/src/ser/pair.rs rename to src/serde_urlencoded/ser/pair.rs index 8fedcc0aa..37f984755 100644 --- a/serde_urlencoded/src/ser/pair.rs +++ b/src/serde_urlencoded/ser/pair.rs @@ -1,7 +1,7 @@ -use ser::Error; -use ser::key::KeySink; -use ser::part::PartSerializer; -use ser::value::ValueSink; +use super::super::ser::Error; +use super::super::ser::key::KeySink; +use super::super::ser::part::PartSerializer; +use super::super::ser::value::ValueSink; use serde::ser; use std::borrow::Cow; use std::mem; diff --git a/serde_urlencoded/src/ser/part.rs b/src/serde_urlencoded/ser/part.rs similarity index 85% rename from serde_urlencoded/src/ser/part.rs rename to src/serde_urlencoded/ser/part.rs index 36ce1414b..2ce352d24 100644 --- a/serde_urlencoded/src/ser/part.rs +++ b/src/serde_urlencoded/ser/part.rs @@ -1,7 +1,8 @@ -use dtoa; -use itoa; -use ser::Error; -use serde::ser; +use ::serde; + +use super::super::dtoa; +use super::super::itoa; +use super::super::ser::Error; use std::str; pub struct PartSerializer { @@ -25,7 +26,7 @@ pub trait Sink: Sized { fn serialize_string(self, value: String) -> Result; fn serialize_none(self) -> Result; - fn serialize_some + fn serialize_some (self, value: &T) -> Result; @@ -33,16 +34,16 @@ pub trait Sink: Sized { fn unsupported(self) -> Error; } -impl ser::Serializer for PartSerializer { +impl serde::ser::Serializer for PartSerializer { type Ok = S::Ok; type Error = Error; - type SerializeSeq = ser::Impossible; - type SerializeTuple = ser::Impossible; - type SerializeTupleStruct = ser::Impossible; - type SerializeTupleVariant = ser::Impossible; - type SerializeMap = ser::Impossible; - type SerializeStruct = ser::Impossible; - type SerializeStructVariant = ser::Impossible; + type SerializeSeq = serde::ser::Impossible; + type SerializeTuple = serde::ser::Impossible; + type SerializeTupleStruct = serde::ser::Impossible; + type SerializeTupleVariant = serde::ser::Impossible; + type SerializeMap = serde::ser::Impossible; + type SerializeStruct = serde::ser::Impossible; + type SerializeStructVariant = serde::ser::Impossible; fn serialize_bool(self, v: bool) -> Result { self.sink.serialize_static_str(if v { "true" } else { "false" }) @@ -119,7 +120,7 @@ impl ser::Serializer for PartSerializer { self.sink.serialize_static_str(variant.into()) } - fn serialize_newtype_struct + fn serialize_newtype_struct (self, _name: &'static str, value: &T) @@ -127,7 +128,7 @@ impl ser::Serializer for PartSerializer { value.serialize(self) } - fn serialize_newtype_variant + fn serialize_newtype_variant (self, _name: &'static str, _variant_index: u32, @@ -141,7 +142,7 @@ impl ser::Serializer for PartSerializer { self.sink.serialize_none() } - fn serialize_some(self, + fn serialize_some(self, value: &T) -> Result { self.sink.serialize_some(value) @@ -207,7 +208,7 @@ impl PartSerializer { let mut buf = [b'\0'; 20]; let len = itoa::write(&mut buf[..], value).unwrap(); let part = unsafe { str::from_utf8_unchecked(&buf[0..len]) }; - ser::Serializer::serialize_str(self, part) + serde::ser::Serializer::serialize_str(self, part) } fn serialize_floating(self, value: F) -> Result @@ -216,6 +217,6 @@ impl PartSerializer { let mut buf = [b'\0'; 24]; let len = dtoa::write(&mut buf[..], value).unwrap(); let part = unsafe { str::from_utf8_unchecked(&buf[0..len]) }; - ser::Serializer::serialize_str(self, part) + serde::ser::Serializer::serialize_str(self, part) } } diff --git a/serde_urlencoded/src/ser/value.rs b/src/serde_urlencoded/ser/value.rs similarity index 95% rename from serde_urlencoded/src/ser/value.rs rename to src/serde_urlencoded/ser/value.rs index e4e1f2ce3..ef63b010d 100644 --- a/serde_urlencoded/src/ser/value.rs +++ b/src/serde_urlencoded/ser/value.rs @@ -1,5 +1,5 @@ -use ser::Error; -use ser::part::{PartSerializer, Sink}; +use super::super::ser::Error; +use super::super::ser::part::{PartSerializer, Sink}; use serde::ser::Serialize; use std::str; use url::form_urlencoded::Serializer as UrlEncodedSerializer;