Commit Graph

37 Commits

Author SHA1 Message Date
David Tolnay
4ed0362c8e
Panic by default in serde_test is_human_readable
The serde_test Serializer and Deserializer panic in is_human_readable unless the
readableness has been set explicitly through one of the hidden functions. This
is to force types that have distinct readable/compact representations to be
tested explicitly in one or the other, rather than with a plain assert_tokens
which arbitrarily picks one.

We need to follow up by designing a better API in serde_test to expose this
publicly. For now serde_test cannot be used to test types that rely on
is_human_readable. (The hidden functions are meant for our test suite only.)
2017-10-17 09:49:42 -07:00
David Tolnay
030459a040 Merge pull request #1044 from Marwes/human_readable
Serialize to binary if the serde format is not human readable
2017-10-15 16:39:58 -07:00
Markus Westerlind
e36915300f Properly deserialize non-readable IpAddr and SocketAddr 2017-09-14 17:08:17 +02:00
Markus Westerlind
ad3335e5d6 Serialize non-human-readble ip addresses as tuples
Since we know exactly how many bytes we should serialize as we can hint
to the serializer that it is not required which further reduces the
serialized size when compared to just serializing as bytes.
2017-09-11 15:54:53 +02:00
Markus Westerlind
0dccbb1f11 Serialize to binary if the serde format is not human readable
This implements the KISS suggested in https://github.com/serde-rs/serde/issues/790.
It is possible that one of the other approaches may be better but this
seemed like the simplest one to reignite som discussion.

Personally I find the original suggestion of adding two traits perhaps slightly
cleaner in theory but I think it ends up more complicated in the end
since the added traits also need to be duplicated to to the `Seed`
traits.

Closes #790
2017-09-07 16:20:57 +02:00
Steven Fackler
95407a4ca5 Support field ident deserialization from u32 2017-09-05 21:55:33 -07:00
David Tolnay
972da59ebc
Deserialize unsized Arc and Rc 2017-09-04 10:56:42 -07:00
David Tolnay
d965367238
No longer need feature(into_boxed_c_str) 2017-08-15 22:08:23 -07:00
Wangshan Lu
0084d82a50 Add tests for SystemTime 2017-07-12 12:01:40 +08:00
Paul Collier
f347b2d363 impl Deserialize for &'a Path 2017-05-10 13:03:03 -04:00
David Tolnay
15341780a2
Use struct variants in test suite 2017-04-19 13:06:31 -07:00
David Tolnay
26a6ba177c
Remove error from serde_test public API 2017-04-19 11:54:48 -07:00
David Tolnay
86deb8db79
Remove seq_fixed_size in favor of tuple 2017-04-17 12:07:49 -07:00
David Tolnay
3f920f645c
License boilerplate 2017-04-13 17:34:42 -07:00
David Tolnay
ea8fb97beb
Format in rfc style 2017-04-13 12:32:29 -07:00
David Tolnay
1986c17052
Remove conversion from empty seq to unit struct 2017-04-09 13:08:05 -07:00
David Tolnay
e66033e53e
Remove implicit conversion from float to integer 2017-04-05 11:25:12 -07:00
David Tolnay
51d3fb1ebc
Update token names in test suite 2017-04-05 10:40:14 -07:00
David Tolnay
67ed7a0edd
Eliminate Sep tokens in serde_test 2017-04-05 09:42:27 -07:00
David Tolnay
c3d9b42cdf
Fix handling of option and newtype in IgnoredAny 2017-04-05 09:19:22 -07:00
David Tolnay
cabc299447 Merge pull request #839 from serde-rs/conv
Remove questionable type conversions
2017-04-05 08:11:50 -07:00
David Tolnay
b43554fbb1
Require slice of tokens in serde_test::Deserializer 2017-04-05 00:22:00 -07:00
David Tolnay
5871fb9ce0
Remove lifetime from serde_test::Token 2017-04-05 00:17:50 -07:00
David Tolnay
d03ecda333
Test that conversions do not happen 2017-04-04 18:50:40 -07:00
David Tolnay
7a722d5060
Remove questionable conversion tests 2017-04-04 18:38:58 -07:00
Alex Crichton
ce687431f3 Implement Serialize/Deserialize for OsStr/OsString
This commit implements the two serde traits for the libstd `OsStr` and
`OsString` types. This came up as a use case during implementing sccache where
we're basically just doing IPC to communicate paths around. Additionally the
`Path` and `PathBuf` implementations have been updated to delegate to the os
string ones.

These types are platform-specific, however, so the serialization/deserialization
isn't trivial. Currently this "fakes" a newtype variant for Unix/Windows to
prevent cross-platform serialization/deserialization. This means if you're doing
IPC within the same OS (e.g. Windows to Windows) then serialization should be
infallible. If you're doing IPC across platforms (e.g.  Unix to Windows) then
using `OsString` is guaranteed to fail as bytes from one OS won't deserialize on
the other (even if they're unicode).
2017-03-27 11:44:50 -07:00
Robert O'Callahan
cc0d045f5c Add Deserialize impl for std::ops::Range
Resolves #796
2017-03-10 08:39:34 +13:00
David Tolnay
dd6989d551
Actually run unstable tests 2017-03-08 21:02:15 -08:00
Jon Gjengset
0c2fed49e2
Add Deserialize impl for CStr
Fixes #810
2017-03-08 23:57:26 -05:00
David Tolnay
cc06f070d1
Use the existing CString error message 2017-03-05 13:59:18 -08:00
Jon Gjengset
d90eecd4a2
Add tests for CStr(ing) ser/de 2017-03-03 18:06:04 -05:00
David Tolnay
75e6da02d3
Split up test suite so it compiles in parallel 2017-02-24 15:39:18 -08:00
David Tolnay
3d6e086d3e
Support custom paths in container attribute serde(default="...") 2017-02-20 17:06:00 -08:00
Thomas de Zeeuw
9444db5f19 Add support for #[serde(default)] on structs
This allows structs to use the default value for each field defined in
the struct’s `std::default::Default` implementation, rather then the
default value for the field’s type.

```
struct StructDefault {
    a: i32,
    b: String,
}

impl Default for StructDefault {
    fn default() -> StructDefault {
        StructDefault{
            a: 100,
            b: "default".to_string(),
        }
    }
}
```

The code above will now return `100` for field `a` and `”default”` for
`b`, rather then `0` and `””` respectively.
2017-02-20 22:35:31 +01:00
David Tolnay
ff21d557c7
Untagged and internally tagged enums 2017-02-02 18:48:30 -08:00
David Tolnay
a9b5cc4830
Fix invalid_length message for tuples and arrays 2017-01-28 15:00:54 -08:00
David Tolnay
7a2bfdc1dd
Consistent underscores in root directory 2017-01-25 20:45:33 -08:00