This field can be absent in some contextes, notably in the responses
to the /sync endpoint, where the events are summarised in the initial
sync of a client.
Fixes#19
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>
Cargo treats updates in the third position of the version number as
compatible and updates them silently. Therefore, we can drop this number
in the config.
`Tokens` was moved from *quote* to *proc_macro2* and got renamed to
`TokenStream`.
The `hyper::Request` and `Response` used in *ruma-client* require a type
parameter that implements `hyper::body::Payload`, but no implementation
for `Vec<u8>` is provided by a crate. Therefore, the best is to use
`hyper::Body` in the macros.
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>