Commit Graph
47 Commits
Author SHA1 Message Date
Thomas Bahn 0b5e91d430 feat: Add deserializers that use visitors.
This deserializers can be used to delegate deserialization to another
type's visitor.

Example:
```json
fn visit_map<V>(&mut self, visitor: V) -> Result<Self::Value, V::Error>
    where V: de::MapVisitor
{
    let mut deserializer = de::value::MapVisitorDeserializer::new(visitor);
    try!(Deserialize::deserialize(&mut deserializer))
}
```
2015-10-08 15:22:02 +02:00
Thomas Bahn e0429cdd96 style: remove the redundant Error suffix 2015-10-06 01:37:39 +02:00
Thomas Bahn 7413bbb7bf feat: ValueDeserializers are generic over the error type
This makes it possible to remove the `From<de::value::Error>` trait
bound from the `de::Error` trait.

An example for using a `ValueDeserializer` to forward deserializing to
another type's visitor:

```rust
fn visit_u8<E>(&mut self, value: u8) -> Result<Self::Value, E>
    where E: de::Error
{
    try!(Deserialize::deserialize(&mut value.into_deserializer()))
}
```

Please note that there is an regression in serde-rs/json which needs to
be fixed.
2015-10-06 01:37:39 +02:00
Thomas Bahn 0a65153634 fix: forward more errors in de::value::Error
When using a `ValueDeserializer` errors produced with the methods
`type_mismatch`, `length_mismatch` and `syntax` were not forwarded
correctly. These methods now store all information in the enum
`de::value::Error`.
2015-10-05 23:40:36 +02:00
Thomas Bahn 15794a5ed6 Improve build time 2015-05-16 14:36:28 +02:00
Thomas Bahn 62058962de Add deserialiation implementations for fixed size arrays 2015-05-16 14:19:22 +02:00
Thomas Bahn 7d52366403 Add serialization implementations for fixed size arrays 2015-05-16 14:18:32 +02:00
Thomas Bahn 399231ad5e Follow rust std: Use full range for slicing 2015-02-24 10:53:42 +01:00
Thomas Bahn 0388c69228 Follow rust: Suffix us is replaced by usize 2015-02-24 10:52:54 +01:00
Thomas Bahn 61c38127af Follow rust std: Stabilized Hash and introduced PhantomData 2015-02-24 10:52:10 +01:00
Thomas Bahn e9c7ea1a64 Follow rustc: Compiler internals changed 2015-02-24 10:45:34 +01:00
Thomas Bahn d43946b6a6 Fix the json object delimiters
Write "{" instead of "{{". Same for the counterpart.
2015-02-16 20:50:41 +01:00
Thomas Bahn 648ae2e3a3 Ignore serde2/Cargo.lock in git 2015-02-06 22:57:50 +01:00
Thomas Bahn f18c28161d Follow rust std: Peekable changed signature 2015-02-06 22:27:19 +01:00
Thomas Bahn 70e8556e07 Follow rustc: New destructor semantics 2015-02-06 22:27:19 +01:00
Thomas Bahn 03820f3d78 Switch to rustc_serialize for tests 2015-02-06 22:27:19 +01:00
Thomas Bahn f2a6f0e710 Follow rust std: fmt::Writer is implemented by String 2015-02-06 22:23:16 +01:00
Thomas Bahn 1cf41295c7 Add feature gate io 2015-02-06 22:23:16 +01:00
Thomas Bahn a87fab9ecc Simplify some code using auto-deref 2015-02-06 22:23:16 +01:00
Thomas Bahn 81f84a4ea4 Remove unneeded mut specifiers 2015-02-06 22:23:16 +01:00
Thomas Bahn 79ff9fdafa Use the IntoIterator trait in for loops 2015-02-06 22:23:16 +01:00
Thomas Bahn cb8492d74b Follow rust std: Error requires an implementation of fmt::Display 2015-02-06 22:23:16 +01:00
Thomas Bahn 5782657502 Follow rust std: The old io module is now called old_io 2015-02-06 22:23:16 +01:00
Thomas Bahn 9a284ae7c2 Follow rust std: fmt::Show was renamed to fmt::Debug 2015-02-06 22:23:16 +01:00
Thomas Bahn 5dd077969c Use slicing syntax instead of .as_slice() 2015-02-06 22:23:16 +01:00
Thomas Bahn 3022d7301a Use deref coercions when possible 2015-02-06 22:23:15 +01:00
Thomas Bahn 361acd37d0 Follow rust std: int, uint were renamed to isize, usize 2015-02-06 22:23:15 +01:00
Thomas Bahn 3b5d71fbb5 Add empty associated_types in expand_derive 2015-02-06 16:51:11 +01:00
Thomas Bahn d09b9eb72c Unboxed closures: function signature of expand* changed 2015-01-02 13:32:54 +01:00
Thomas Bahn 814c0570b8 Fix: String::from_utf8 became stable and changed signature 2015-01-01 14:22:23 +01:00
Thomas Bahn ae665a1c05 Syntax extension internals in rust changed
See https://github.com/rust-lang/rust/commit/e656081b700b949bc914fedd6ad29b1ca3197660
2015-01-01 14:22:23 +01:00
Thomas Bahn 85d0c8e4e8 Rename FP* to FpCategory::* following std changes 2014-12-30 14:52:27 +01:00
Thomas Bahn 879baec029 Fix: String::from_utf8 changed function signature
Following a rust std change.
2014-12-23 18:35:26 +01:00
Thomas Bahn a276ec4bba Fix: Utf16 handling moved from std into unicode crate
Following a rust change.
2014-12-23 18:35:00 +01:00
Thomas Bahn 17ffa65cb2 Replace StrAllocating with String type in function parameters
The key parameter of the insert functions are of type String now.
As insert requires ownership of its parameter `key` and StrAllocating
being gone in rust these functions now communicate that ownership
in their signature.

As a result &str must be converted into a String at the caller instead
of the callee.

The Trait ToOwned isn't an alternative as it's a generalized Clone.
StrAllocating simply has hidden an allocation or move.
2014-12-23 18:34:20 +01:00
Thomas Bahn 512a54e983 Replace TreeMap with BTreeMap in the serde2 2014-12-23 18:33:37 +01:00
Thomas Bahn 7fa62b6212 Fix: Append semicolon to item macro invocations in serde2
Following changes in rustc.
2014-12-23 18:31:22 +01:00
Thomas Bahn 589a07d4c9 Silence deprecation warnings
str::char_len() is deprecated in favour of chars().count()
2014-12-23 18:05:58 +01:00
Thomas Bahn 91cfb003d9 Fix: String::from_utf8 changed function signature
Following a rust std change.
2014-12-23 18:05:58 +01:00
Thomas Bahn 3cf0fb8d5b Fix: Utf16 handling moved from std into unicode crate
Following a rust change.
2014-12-23 18:05:58 +01:00
Thomas Bahn 0957d5769d Replace StrAllocating with String type in function parameters
The key parameter of the insert functions are of type String now.
As insert requires ownership of its parameter `key` and StrAllocating
being gone in rust these functions now communicate that ownership
in their signature.

As a result &str must be converted into a String at the caller instead
of the callee.

The Trait ToOwned isn't an alternative as it's a generalized Clone.
StrAllocating simply has hidden an allocation or move.
2014-12-23 18:05:58 +01:00
Thomas Bahn cca63836d2 Replace MoveItems and MoveEntries with IntoIter
Following a rust std change.
2014-12-23 18:05:58 +01:00
Thomas Bahn 681a609844 Replace TreeMap with BTreeMap in the serde tests 2014-12-23 17:44:26 +01:00
Thomas Bahn 19bda6a90d Replace TreeMap/TreeSet with BTreeMap/BTreeSet in serde
Follow rust std changes:
https://github.com/rust-lang/rfcs/blob/master/text/0509-collections-reform-part-2.md
2014-12-20 14:42:48 +01:00
Thomas Bahn aad0854beb Fix item macro invocation in benches
Following changes in rustc.
2014-12-19 15:43:54 +01:00
Thomas Bahn 3ea0c7e850 Append semicolon to item macro invocations in serde2
Following changes in rustc.
2014-12-19 09:17:51 +01:00
Thomas Bahn d6807c0e90 Append semicolon to item macro invocations in serde
Following changes in rustc.
2014-12-19 08:59:11 +01:00