112 Commits

Author SHA1 Message Date
bors[bot]
2aba0def87 Merge #59
59: Expose lifetimes in UrlEncodedSerializer r=nox a=benesch

Forcing UrlEncodedSerializer to have a 'static lifetime is unnecessarily
restrictive and breaks a downstream dependency, reqwest. Thread a new
lifetime through to fix the problem.

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
2019-07-31 08:27:48 +00:00
Nikhil Benesch
31641affad
Expose lifetimes in UrlEncodedSerializer
Forcing UrlEncodedSerializer to have a 'static lifetime is unnecessarily
restrictive and breaks a downstream dependency, reqwest. Thread a new
lifetime through to fix the problem.
2019-07-30 13:26:36 -04:00
bors[bot]
4250a6bcd9 Merge #51
51: feat: allow serialization of unit structs r=nox a=fdehau

fix #50 

Co-authored-by: Florian Dehau <work@fdehau.com>
2019-07-30 07:41:19 +00:00
bors[bot]
68113de90f Merge #57
57: Update the url crate to 2.0 r=nox a=SimonSapin



Co-authored-by: Simon Sapin <simon.sapin@exyr.org>
2019-07-30 07:37:26 +00:00
Simon Sapin
59f990aba4
url is a public dependency, so updating it to 2.0 is a breaking change 2019-07-29 10:19:29 +02:00
Simon Sapin
99ef71ac2e Update the url crate to 2.0 2019-07-24 16:59:16 +02:00
Florian Dehau
76b45ee001 feat: allow serialization of unit structs 2019-04-18 08:21:54 +02:00
bors[bot]
643a206559 Merge #54
54: Don't use CowStrDeserializer (fixes #53) r=nox a=nox



Co-authored-by: Anthony Ramine <n.oxyde@gmail.com>
2019-04-16 09:29:19 +00:00
Anthony Ramine
2bb996055b Bump version to 0.5.5 2019-04-16 11:27:24 +02:00
Anthony Ramine
98f0113592 Don't use CowStrDeserializer (fixes #53) 2019-04-16 11:26:25 +02:00
Anthony Ramine
92eadc25be Reformat 2019-04-16 11:15:32 +02:00
bors[bot]
11cc5bb88f Merge #45
45: Fix struct newtype deserialization (and add tests) r=nox a=samsieber

Fixes #41

I only had to fix the deserializer - the serialization already works. So now they work the same way - you can serialize something and then deserialize it losslessly. 

I also added tests for serialization and deserialization. Let me know if there's anything you'd like changed.

Co-authored-by: Sam Sieber <swsieber@gmail.com>
2018-11-19 16:16:45 +00:00
Sam Sieber
8f829ac1b4 Bump version to 0.5.4 2018-11-19 09:12:33 -07:00
Sam Sieber
0ecc730e64 Fix struct newtype deserialization (and add tests) 2018-11-19 08:59:04 -07:00
bors[bot]
199ed02274 Merge #30
30: Support deserializing a (keyword) string into a unit-only enum r=nox a=smangelsdorf

This adds support for deserializing a structure such as:

```rust
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
enum SortOrder {
    Asc,
    Desc,
}

#[derive(Serialize, Deserialize, Debug)]
struct SearchOptions {
    sort: SortOrder,
}
```

This is already supported for serialization (and I've added a test case for the existing support as part of this PR), but attempting to deserialize the string `"sort=asc"` would result in the error:

```
invalid type: string "asc", expected enum SortOrder
```

I've made a sample in the playground of the way this is handled in `serde_urlencoded` vs `serde_json`: https://play.rust-lang.org/?gist=75fc1e5bbbc1eec29a472373d47488a0&version=stable

This brings the behaviour in line with the way `serde_json` currently handles this case, which I hope is appropriate. Happy to tweak the behaviour if there's a better way to handle it.

Co-authored-by: Shaun Mangelsdorf <s.mangelsdorf@gmail.com>
2018-08-14 10:53:15 +00:00
Shaun Mangelsdorf
4d220818f7 Implement deserialization into unit enums 2018-08-14 12:52:36 +02:00
bors[bot]
3ae5332931 Merge #32
32: Bump version to 0.5.2 r=nox a=nox



Co-authored-by: Anthony Ramine <n.oxyde@gmail.com>
2018-05-16 10:19:15 +00:00
Anthony Ramine
147bc9d93f Bump version to 0.5.2 2018-05-15 22:19:04 +02:00
bors[bot]
f1499760e3 Merge #31
31: Bump itoa dep to 0.4.0 r=nox a=alex



Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2018-05-15 19:58:04 +00:00
Alex Gaynor
b4804ad95a
Bump itoa dep to 0.4.0 2018-03-19 09:53:30 -04:00
bors[bot]
bdb7468bcb Merge #25
25: Deserialize () from input without key/value pairs. r=nox
Currently there's no input that can be deserialized to `()`, this changes the crate to support deserializing strings without any key/value pair to a `()` (such as the empty string, or just `"&"`).

Would be great if you could release a patch for this, I have a project that needs this behavior.

EDIT: To expand on my use case, I have a trait which parses the body of an HTTP Request into a type (e.g. for a `POST` request). However, this is abstract over HTTP methods, and its expected to be able to parse an empty body (e.g. from a `GET` request) into `()`.
2017-05-21 07:34:36 +00:00
Without Boats
ecb91cfcd7 Deserialize () from input without key/value pairs. 2017-05-21 00:28:04 -07:00
bors[bot]
c5839b94e5 Merge #23
23: Update to serde 1.0.0 r=nox
2017-05-08 21:39:52 +00:00
Ted Driggs
abb8d81f9f Update to serde 1.0.0 2017-05-08 17:18:53 +02:00
bors[bot]
43858d329e Merge #22
22: Have a custom type for deserialising values (fixes #16) r=nox
2017-05-06 09:06:51 +00:00
Anthony Ramine
81aad8e8bd Bump version to 0.4.3 2017-05-06 11:06:12 +02:00
Anthony Ramine
7ddde33a33 Have a custom type for deserialising values (fixes #16)
This lets us handle Option values correctly.
2017-05-06 10:59:42 +02:00
Anthony Ramine
f122a88561 Reformat de 2017-05-06 10:43:25 +02:00
bors-ng[bot]
c0457909e4 Merge #13
13: Inline docs of reexports and bump version to 0.4.2
2017-02-05 13:47:23 +00:00
Anthony Ramine
a8def0d865 Inline docs of reexports and bump version to 0.4.2 2017-02-05 14:46:33 +01:00
bors-ng[bot]
9931bc5318 Merge #12
12: implement deserialization of std::io::Read
2017-02-05 13:36:49 +00:00
Arthur Skobara
8839c6a86c Introduce de::from_reader 2017-02-05 14:34:14 +01:00
bors-ng[bot]
4ef7cc6e85 Merge #11
11: Update serde to 0.9.3 and use serde::ser::Impossible
2017-01-31 09:59:17 +00:00
Anthony Ramine
b24505bcfe Bump to 0.4.1 2017-01-31 10:57:22 +01:00
Anthony Ramine
a2fb94e32d Add a couple of categories 2017-01-31 10:57:10 +01:00
Anthony Ramine
bc8197c884 Update serde to 0.9.3 and use serde::ser::Impossible 2017-01-31 10:52:21 +01:00
bors-ng[bot]
2cc32847ac Merge #10
10: Update to serde 0.9.0 and various improvements
2017-01-29 09:30:09 +00:00
Anthony Ramine
3e9ebe4fd7 Bump version to 0.4.0 2017-01-29 10:25:43 +01:00
Anthony Ramine
fba478f827 Add bors configuration 2017-01-29 10:25:43 +01:00
Anthony Ramine
f5b1ae8828 Do not forbid bool keys anymore
Floats are supported so...
2017-01-29 10:22:40 +01:00
Anthony Ramine
5625c254e5 Use dtoa to not allocate a String to serialize a float 2017-01-29 10:22:40 +01:00
Anthony Ramine
1d88bbb26b Use itoa to not allocate a String to serialize an integer 2017-01-29 10:22:39 +01:00
Anthony Ramine
e140c2b5c5 Use void for the unreachable serializers 2017-01-29 10:22:39 +01:00
Anthony Ramine
fa8fb69da0 Do not allocate a String to serialize a bool 2017-01-29 10:22:39 +01:00
Anthony Ramine
9960d5af2d Update to serde 0.9.0 (fixes #7) 2017-01-29 10:22:30 +01:00
Anthony Ramine
8e5cf19e07 Reformat with rustfmt 2017-01-27 22:56:04 +01:00
Anthony Ramine
9aefb1c02d Bump version to 0.3.0 2016-10-23 12:25:45 +02:00
Anthony Ramine
5202ee622b Support Option values in the sequence serializer
This allows us to serialize sequences of Option<(K, V)> values.
2016-10-23 12:13:09 +02:00
Anthony Ramine
f9c64eb16c Support serializing top-level Option values 2016-10-23 11:56:27 +02:00
Anthony Ramine
39f7d33b0b Use opaque structs instead of opaque tuples
Opaque struct tuples leak their arity.
2016-10-23 11:55:16 +02:00