From 31b5e882aa9058bf19534ab40ee6efa1ce6b2d73 Mon Sep 17 00:00:00 2001 From: Sam Scott Date: Fri, 10 Mar 2017 13:27:42 -0500 Subject: Cleaning up, modifying docs. --- .travis.yml | 3 --- Cargo.toml | 3 ++- LICENSE-MIT | 1 + bors.toml | 1 - src/lib.rs | 18 +++++++++++++++--- src/ser/key.rs | 6 +++--- src/ser/mod.rs | 7 +++---- src/ser/part.rs | 2 +- src/ser/value.rs | 2 +- 9 files changed, 26 insertions(+), 17 deletions(-) delete mode 100644 bors.toml 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 diff --git a/Cargo.toml b/Cargo.toml index 13b5cbd..de7306d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,12 @@ authors = ["Sam Scott "] # 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"] diff --git a/src/lib.rs b/src/lib.rs index a1ce6c3..f28d916 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 Sink for KeySink 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 _key: &'static str, _value: &T) -> Result<(), Error> { - Err(Error::top_level()) + Err(self.unsupported()) } fn end(self) -> Result { @@ -102,7 +102,7 @@ where End: for<'key> FnOnce(Key<'key>) -> Result fn serialize_element(&mut self, _value: &T) -> Result<(), Error> { - Err(Error::top_level()) + Err(self.unsupported()) } fn end(self) -> Result { 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(input: &T) -> Result { /// 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: Sized + ser::SerializeStruct + ser::Seriali value: &T) -> Result; - fn unsupported(self) -> Error; + fn unsupported(&self) -> Error; } impl> ser::Serializer for PartSerializer { 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()) } } -- cgit v1.2.3