Commit Graph

110 Commits

Author SHA1 Message Date
David Tolnay
28db9d4989
Format with rustfmt 0.99.1 2018-08-06 22:40:28 -07:00
Caio
8b2e6baf78 Implement Serialize and Deserialize for RangeInclusive 2018-08-05 10:45:50 -03:00
David Tolnay
4e54aaf796
Format with rustfmt 0.8.2 2018-07-08 19:02:44 -07:00
David Tolnay
94853752a1
Stabilize some unstable tests in test suite 2018-06-03 00:31:20 -07:00
David Tolnay
22b1af7eb3
Test never_type 2018-06-03 00:22:11 -07:00
David Tolnay
9083cf4b00
Test integer128 impls 2018-05-20 22:17:35 -07:00
David Tolnay
4687c1b52b
Test Weak deserialize impls 2018-05-07 11:23:18 -07:00
David Tolnay
d82d1707d6
Format with rustfmt 0.6.0 2018-04-30 01:42:46 -07:00
David Tolnay
30361ac6d0
Clean up workaround that required too many parentheses
The issue has been fixed in the compiler and these extra call site parentheses
are no longer required.
2018-03-09 00:22:27 -08:00
David Tolnay
9db784bccd
Ignore decimal_literal_representation in test suite 2018-01-29 21:52:21 -08:00
David Tolnay
1bdf5ecec4
Ignore unused_parens warning on the proc macro workaround 2018-01-21 17:54:06 -08:00
David Tolnay
6e01f220b1
Ignore clippy flagging our workaround 2018-01-13 14:28:12 -08:00
David Tolnay
ed6a1de311
Auto format attributes on their own line 2017-12-23 20:24:57 -08:00
David Tolnay
ee75e6c0e9
Format with rustfmt-nightly 0.3.4 2017-12-23 20:17:52 -08:00
David Tolnay
0dac13e4db
Resolve conflict with pr 1115 2017-12-11 20:59:54 -08:00
Jeroen Bollen
c887a0b472 Solved #1105.
When a field should be skipped during deserialization, it will not use its own Default implementation
when the container structure has `#[serde(default)]` set.
2017-12-06 21:14:02 +01:00
David Tolnay
436cafb0a3
Catch wrong field names length in serde_test 2017-11-12 10:16:43 -08:00
Markus Westerlind
aad7a7987f Add an example to the Configure trait 2017-11-06 10:35:22 +01:00
David Tolnay
ab0848f780
Follow clippy advice about unreadable literal 2017-10-31 22:42:12 -07:00
David Tolnay
9b08915a18
Add tests for std::num::Wrapping impls 2017-10-31 09:32:58 -07:00
David Tolnay
9be3d32016
Remove redundant readable/compact tests
This functionality is covered well enough by the std::net types.
2017-10-17 23:16:21 -07:00
David Tolnay
5daf1b89a1
Consolidate readable/compact deserialization tests 2017-10-17 23:15:35 -07:00
David Tolnay
f8f5d0ca2f
No need for readable setting for the ignore test 2017-10-17 23:09:50 -07:00
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