diff options
author | Sam Scott <sam.scott89@gmail.com> | 2017-03-10 13:27:42 -0500 |
---|---|---|
committer | Sam Scott <sam.scott89@gmail.com> | 2017-03-10 13:27:42 -0500 |
commit | 31b5e882aa9058bf19534ab40ee6efa1ce6b2d73 (patch) | |
tree | a3d0b73556985f3e73e7a9c0004c0567ef31645c | |
parent | 6aecad1c9a907c0dc567aef3388bb1857f9ed47d (diff) |
Cleaning up, modifying docs.
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | LICENSE-MIT | 1 | ||||
-rw-r--r-- | bors.toml | 1 | ||||
-rw-r--r-- | src/lib.rs | 18 | ||||
-rw-r--r-- | src/ser/key.rs | 6 | ||||
-rw-r--r-- | src/ser/mod.rs | 7 | ||||
-rw-r--r-- | src/ser/part.rs | 2 | ||||
-rw-r--r-- | src/ser/value.rs | 2 |
9 files changed, 26 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml index 088c2e4..4ecd9b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,3 @@ rust: - nightly - beta - stable -branches: - except: - - staging.tmp @@ -16,11 +16,12 @@ authors = ["Sam Scott <me@samjs.co.uk>"] # test = false [dependencies] +csv = "0.15" fnv = "1.0.3" dtoa = "0.4.0" itoa = "0.3.0" serde = "0.9.3" -serde_derive = "*" +serde_derive = "0.9.8" url = "1.0.0" [profile.release] diff --git a/LICENSE-MIT b/LICENSE-MIT index 39f6303..6e396f3 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,5 @@ Copyright (c) 2016 Anthony Ramine +Copyright (c) 2017 Sam Scott Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/bors.toml b/bors.toml deleted file mode 100644 index 359f894..0000000 --- a/bors.toml +++ /dev/null @@ -1 +0,0 @@ -status = ["continuous-integration/travis-ci/push"] @@ -1,8 +1,20 @@ //! Serde support for querystring-style strings +//! +//! Querystrings are not formally defined and loosely take the form of +//! _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. +//! +//! For users who do *not* require nested URL parameters, it is highly +//! 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`. -#![warn(unused_extern_crates)] - -extern crate fnv; extern crate itoa; extern crate dtoa; #[macro_use] diff --git a/src/ser/key.rs b/src/ser/key.rs index eb7ffae..5b2ccdd 100644 --- a/src/ser/key.rs +++ b/src/ser/key.rs @@ -70,7 +70,7 @@ impl<End, Ok> Sink<Ok, Error> for KeySink<End> Err(self.unsupported()) } - fn unsupported(self) -> Error { + fn unsupported(&self) -> Error { Error::Custom("unsupported key".into()) } } @@ -85,7 +85,7 @@ where End: for<'key> FnOnce(Key<'key>) -> Result<Ok, Error> _key: &'static str, _value: &T) -> Result<(), Error> { - Err(Error::top_level()) + Err(self.unsupported()) } fn end(self) -> Result<Self::Ok, Error> { @@ -102,7 +102,7 @@ where End: for<'key> FnOnce(Key<'key>) -> Result<Ok, Error> fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> { - Err(Error::top_level()) + Err(self.unsupported()) } fn end(self) -> Result<Self::Ok, Error> { diff --git a/src/ser/mod.rs b/src/ser/mod.rs index 596730e..f732bb3 100644 --- a/src/ser/mod.rs +++ b/src/ser/mod.rs @@ -46,11 +46,10 @@ pub fn to_string<T: ser::Serialize>(input: &T) -> Result<String, Error> { /// A serializer for the querystring format. /// -/// * Supported top-level inputs are structs, maps and sequences of pairs, -/// with or without a given length. +/// * Supported top-level inputs are structs and maps. /// -/// * Supported keys and values are integers, bytes (if convertible to strings), -/// unit structs and unit variants. +/// * Supported values are currently most primitive types, structs, maps and +/// sequences. Sequences are serialized with an incrementing key index. /// /// * Newtype structs defer to their inner values. pub struct Serializer<'output, Target: 'output + UrlEncodedTarget> { diff --git a/src/ser/part.rs b/src/ser/part.rs index d456f4b..4cf90b3 100644 --- a/src/ser/part.rs +++ b/src/ser/part.rs @@ -35,7 +35,7 @@ pub trait Sink<S, E>: Sized + ser::SerializeStruct<Ok=S, Error=E> + ser::Seriali value: &T) -> Result<S, Error>; - fn unsupported(self) -> Error; + fn unsupported(&self) -> Error; } impl<SO, S: Sink<SO, Error>> ser::Serializer for PartSerializer<SO, S> { diff --git a/src/ser/value.rs b/src/ser/value.rs index 832cbf3..5ed80b9 100644 --- a/src/ser/value.rs +++ b/src/ser/value.rs @@ -55,7 +55,7 @@ impl<'key, 'target, Target> Sink<(), Error> for ValueSink<'key, 'target, Target> value.serialize(PartSerializer::new(self)) } - fn unsupported(self) -> Error { + fn unsupported(&self) -> Error { Error::Custom("unsupported value".into()) } } |