diff options
author | Sam Scott <sam.scott89@gmail.com> | 2017-03-12 14:44:44 -0400 |
---|---|---|
committer | Sam Scott <sam.scott89@gmail.com> | 2017-03-12 14:44:44 -0400 |
commit | bccdce1a3ac0dc0646f4ffa9bc0a09ea19ae58a5 (patch) | |
tree | 365d4561f44407720f24ec84690611096807c040 /src/lib.rs | |
parent | 317b8b17f3e3656cdc64fc6435889d005aa9a8af (diff) |
Run rustfmt on code.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 53 |
1 files changed, 48 insertions, 5 deletions
@@ -4,16 +4,59 @@ //! _nested_ urlencoded queries. //! //! This library aims for compatability with the syntax of -//! [qs](https://github.com/ljharb/qs) and also of the [Rack::Utils::parse_neste -//! d_query](http://www.rubydoc.info/github/rack/rack/Rack/Utils -//! #parse_nested_query-class_method) implementation. +//! [qs](https://github.com/ljharb/qs) and also of the +//! [Rack::Utils::parse_nested_query](http://www.rubydoc.info/github/rack/rack/Rack/Utils#parse_nested_query-class_method) +//! implementation. //! //! For users who do *not* require nested URL parameters, it is highly -//! recommended that the `serde_urlencoded` crate is used instead, which +//! recommended that the `serde_urlencoded` crate is used instead, which //! will almost certainly perform better for deserializing simple inputs. -//! +//! //! The serialization implementation of this library is adapted from //! `serde_urlencoded`. +//! +//! ## Usage +//! +//! See the examples folder for a more detailed introduction. +//! +//! Serializing/Deserializing is designed to work with maps and structs. +//! +//! ``` +//! +//! +//! #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +//! struct Address { +//! city: String, +//! postcode: String, +//! } +//! #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +//! struct QueryParams { +//! id: u8, +//! name: String, +//! address: Address, +//! phone: u32, +//! user_ids: Vec<u8>, +//! } +//! +//! # fn main() { +//! let params = QueryParams { +//! id: 42, +//! name: "Acme".to_string(), +//! phone: 12345, +//! address: Address { +//! city: "Carrot City".to_string(), +//! postcode: "12345".to_string(), +//! }, +//! user_ids: vec![1, 2, 3, 4], +//! }; +//! let rec_params: QueryParams = qs::from_str("\ +//! name=Acme&id=42&phone=12345&address[postcode]=12345&\ +//! address[city]=Carrot+City&user_ids[0]=1&user_ids[1]=2&\ +//! user_ids[2]=3&user_ids[3]=4") +//! .unwrap(); +//! assert_eq!(rec_params, params); +//! +//! # } extern crate itoa; extern crate dtoa; |