87 Commits

Author SHA1 Message Date
Ragotzy.devin
7972453e91
urlencoded: (de)serialize nested structs as JSON 2020-04-29 09:58:30 +02:00
Jonas Platte
053d2e94f6
Update CI config 2020-04-24 21:53:42 +02:00
Jonas Platte
16acf7f753
CI updates 2020-04-24 18:43:49 +02:00
Jonas Platte
50218e27ab
Add sources to builds.sr.ht manifests 2020-04-24 18:38:37 +02:00
Jonas Platte
1eb5bffbc6
Add builds.sr.ht manifests 2020-04-24 18:29:28 +02:00
Jonas Platte
cb5f8ffc39
Don't use unstable rustfmt options 2020-04-24 12:32:25 +02:00
Jonas Platte
6fa05a1a6f
Update some imports 2020-04-24 12:29:44 +02:00
Jonas Platte
6770ed61c1
Update .gitignore 2020-04-24 12:28:17 +02:00
Jonas Platte
32d95057a6
cargo fmt 2020-04-24 12:17:59 +02:00
Jonas Platte
41288b7c73
Fix warnings 2020-04-24 10:11:35 +02:00
Jonas Platte
c6359d1916
Integrate serde_urlencoded fork 2020-04-24 10:09:19 +02:00
Jonas Platte
afb39536eb Add 'urlencoded/' from commit '93a7283991aa9c9b1087803c274953d3072c3dc0'
git-subtree-dir: urlencoded
git-subtree-mainline: 3e4cd7abd4fa3f87c7de3952a10c65928d93979d
git-subtree-split: 93a7283991aa9c9b1087803c274953d3072c3dc0
2020-04-24 09:43:01 +02:00
Devin R
93a7283991
Add support for matrix-style multiple query parameters
This adds support for query strings in which a sequence field of a
`Deserialize` / `Serialize` struct is (de)serialized as
`field=val1&field=val2&field=val3`, instead of the more common
`field[]=val1&field[]=val2&field[]=val3` syntax.
2020-04-24 09:32:37 +02:00
Devin R
68daaf86f6 update to 2018 edition, import in ruma style 2020-04-20 09:11:41 -04:00
Jonas Platte
3e4cd7abd4
Add LICENSE file, travis configuration 2020-04-17 19:54:23 +02:00
Jonas Platte
c0e751669f
Initial commit (import code from ruma-client-api)
Co-authored-by: Isaiah Inuwa <isaiah.inuwa@gmail.com>
2020-04-17 19:50:14 +02:00
bors[bot]
ab6f3ce278
Merge #68
68: Allow serialization of unit type r=nox a=maxv-rust

That changes provides support for unit type serialization.

It may looks like it doesn't make sense to serialize `()`. Unfortunately that kind of serialization may be necessary for generic structures where one of generic argument may be `()`.

Closes #69 

Co-authored-by: MaxV <60802079+maxv-rust@users.noreply.github.com>
2020-04-16 10:20:06 +00:00
MaxV
f60e4fd093 Allow serialization of unit type 2020-04-08 23:02:57 -07:00
bors[bot]
e659355313
Merge #61
61: chore: Exclude unneeded files r=nox a=ignatenkobrain



Co-authored-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2020-03-10 08:35:20 +00:00
bors[bot]
820c8a0b84
Merge #67
67: replace typo in documentation r=nox a=mcginty

It caught me when I was reading it :).

Co-authored-by: Jake McGinty <me@jake.su>
2020-03-10 08:33:32 +00:00
Jake McGinty
12c95203e0 replace typo in documentation 2020-03-10 12:38:30 +09:00
bors[bot]
bf16076bce Merge #64
64: Add Error::source r=nox a=AnderEnder

As discussed in https://github.com/nox/serde_urlencoded/pull/63 `Error::source` was added in `1.30.0`

This PR implements `Error::source`

Co-authored-by: Andrii Radyk <ander.ender@gmail.com>
2020-02-10 11:15:28 +00:00
Andrii Radyk
ed2b92f98b add Error::source 2020-01-20 23:07:27 +01:00
Igor Gnatenko
eb3c523444
chore: Exclude unneeded files 2019-08-25 14:10:44 +02:00
Anthony Ramine
278de79267 Bump version to 0.6.1 2019-07-31 10:49:32 +02:00
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