Erick Tryzelaar
b842164fd8
feat(codegen): Support renames that are different when serializing and deserializing
...
According to #61 , if one uses serde to serialize requests that pass
url-encoded parameters to a server, it might get responses back
with a different capitalization scheme. This patch restores the
behavior implemented in #62 .
# Conflicts:
# serde_codegen/src/attr.rs
# serde_codegen/src/de.rs
# serde_tests/tests/test_annotations.rs
2016-02-08 10:43:41 -08:00
Erick Tryzelaar
365e5129af
refactor(codegen): Add VariantAttrs
2016-02-08 10:43:32 -08:00
Erick Tryzelaar
d0ee5b0b4b
feat(codegen): Remove {Ser,Deser}ializer::format
...
This feature has never been used, and it's complicating the
implementation of #207 . We could restore this functionality if there is
ever interest in it.
Closes #211 .
2016-02-08 10:10:00 -08:00
Erick Tryzelaar
f1b20577d3
feat(ser): Add ser::Error trait; avoid panic when serializing Paths
...
The only way to safely serialize a `Path` is to use
`.to_string_lossy()`, which replaces invalid UTF-8 characters with
the U+FFFD replacement character. Unfortunately this would lose
information, so for our default implementations, it'd be better
to punt and report an error, and leave it up to the user to
decide if they want to use the lossy encoding.
Unfortunately, we had no way for `Serializer`s to require some methods
on `Serializer::Error`, so there was no way before this patch for
the `Path` implementation to generically report that it cannot encode
this value. This adds that implementation.
breaking-change
Closes #57 .
2016-01-28 10:41:21 -08:00
Erick Tryzelaar
9ae47a261e
Merge branch 'v0.6.x'
...
# Conflicts:
# serde/src/de/impls.rs
# serde_codegen/src/de.rs
2016-01-28 09:49:15 -08:00
Erick Tryzelaar
4507eaec5b
Use deserializer.visit_string for PathBuf
2016-01-28 09:45:38 -08:00
Erick Tryzelaar
42b8b6153e
Merge branch 'v0.6.x' into master
...
# Conflicts:
# serde/Cargo.toml
# serde/src/ser/impls.rs
# serde_codegen/src/attr.rs
# serde_codegen/src/de.rs
# serde_codegen/src/field.rs
# serde_codegen/src/ser.rs
2016-01-18 12:45:39 -08:00
Erick Tryzelaar
8df841f048
fix(errors): Report errors on unknown #[serde(...)] attributes
...
Closes #51 , #175 , and #187
2016-01-18 12:39:46 -08:00
Erick Tryzelaar
bfa2b69193
feat(clippy): Use clippy for it's extra lints
2016-01-18 12:24:03 -08:00
John Heitmann
8c57f433ff
s/disallow_unknown/deny_unknown_fields/
2016-01-11 10:20:07 -08:00
John Heitmann
bfac1a581c
Implemented disallow_unknown
...
* Added codegen for disallow_unknown
* ... with new default to ignore unknown values during deserialization
* Added ContainerAttrs
2016-01-10 19:34:48 -08:00
Erick Tryzelaar
e1a44293c0
Merge pull request #162 from skade/std-error
...
Have serde:🇩🇪 :Error require std::error::Error
2015-12-08 14:10:45 -05:00
Erick Tryzelaar
188425ffe5
Merge branch 'v0.6.x' into master
...
# Conflicts:
# serde_codegen/Cargo.toml
2015-12-08 09:50:10 -05:00
Erick Tryzelaar
1a8a11e924
feat(impls): Add impls for num::{BigInt,BigUint,Complex,Ratio}
2015-12-01 09:03:08 -08:00
Oliver Schneider
51912e6197
test( #151 ): update tests and benchmarks: visit -> (de)serialize
2015-10-20 09:30:15 +02:00
Erick Tryzelaar
55de7bd99b
fix(tests): Get tests to compile with new value deserializer scheme
2015-10-19 08:33:57 -07:00
Florian Gilcher
fc19895237
Have serde: 🇩🇪 :Error require std::error::Error
2015-09-24 07:03:36 -07:00
Erick Tryzelaar
c4392ff256
feat(codegen): Add more attributes to skip serializing
...
These attributes are `#[serde(skip_serializing_if_none)]` and
`#[serde(skip_serializing_if_empty)]`.
2015-09-07 16:58:52 -07:00
Erick Tryzelaar
fa3460e0a7
Migrate serde_json into it's own repo
...
New location is https://github.com/serde-rs/json .
2015-08-29 18:09:51 -07:00
Erick Tryzelaar
42069ca669
Refactor tests to not use serde_json
2015-08-29 17:29:42 -07:00
Erick Tryzelaar
fe20852b2c
Reject serializing maps to JSON with non-string keys
...
Closes #122 . This is a breaking change since it modifies the
return type of serde_json::to_vec{,pretty}, so it'll require a major
version bump of serde_json.
2015-08-13 22:29:13 -07:00
Erick Tryzelaar
7fb2bd50bf
Add a string argument to Error::syntax()
2015-08-07 08:08:56 -07:00
Erick Tryzelaar
2aeb51ad51
Remove "_error" from de::Error::*_error
2015-08-07 07:53:22 -07:00
Erick Tryzelaar
1d9c707a76
Rewrite json parser to not require consuming the full stream
...
Closes #89
2015-08-06 11:12:37 -07:00
Erick Tryzelaar
fd84aec485
Fix parsing min, max, and epsilon f64 values
2015-08-05 08:15:47 -07:00
Erick Tryzelaar
ed6777e59f
Fix json parsing i64::MIN, add tests for min and max i64 and u64 values
2015-08-03 09:09:44 -07:00
Erick Tryzelaar
8eff38b6f6
Eliminate some code duplication parsing an exponent as an integer
2015-08-01 13:50:42 -07:00
Erick Tryzelaar
23031d057f
Add test for parsing json "0" and "0.0"
2015-07-31 07:33:23 -07:00
Erick Tryzelaar
97528b59cf
Add support for serializing newtype structs
...
This enables formats like JSON to serialize newtype wrapper
structs without the normal object wrapper. Consider types like:
```rust
struct Point {
x: u32,
y: u32,
}
stuct MyPoint(Point);
```
Before this patch, `MyPoint(1,2)` would get serialized as
`[{"x":1,"y":2}]`, but now it gets serialized as `{"x":1,"y"2}`.
2015-07-31 07:22:13 -07:00
Erick Tryzelaar
6715fb6652
Rename visit_simple to visit_newtype
2015-07-31 07:22:13 -07:00
Erick Tryzelaar
fefc010deb
Rename visit_enum_simple to visit_newtype_variant
2015-07-31 07:22:13 -07:00
Erick Tryzelaar
5a56394814
Add test to deserialize variants from usize and &[u8]
2015-07-30 08:06:04 -07:00
Erick Tryzelaar
97f08086dd
Have visit_enum_simple default to calling visit_tuple_variant
2015-07-30 08:06:04 -07:00
Erick Tryzelaar
0348a3914d
Pass variant index to visit_enum_simple
2015-07-30 08:06:04 -07:00
Erick Tryzelaar
5dc245d2ce
Switch serializing Result to using simple enums
2015-07-30 08:06:04 -07:00
Erick Tryzelaar
2cb7d66767
Add test for deserializing a simple enum
2015-07-30 08:06:04 -07:00
Erick Tryzelaar
49fa208242
Minor cleanup
2015-07-30 08:06:04 -07:00
Erick Tryzelaar
d2fef27721
Rename ser::Serializer::visit_enum_{unit,seq,map} to visit_{unit,tuple,struct}_variant
2015-07-30 06:45:21 -07:00
Erick Tryzelaar
351b7039a8
Rename de::VariantVisitor::visit_{map,seq} to visit_{struct,tuple}
2015-07-30 06:45:21 -07:00
Erick Tryzelaar
6c9cebdcc3
Pass the variant fields and tuple lengths into visit_{enum,tuple,tuple_struct}
2015-07-30 06:45:21 -07:00
Erick Tryzelaar
0058e3a8d4
Merge pull request #111 from oli-obk/master
...
tuple enums with single element should not be a json-array
2015-07-29 13:35:43 -07:00
Oliver Schneider
5f1cb9b96c
rebased again
2015-07-24 09:31:35 +02:00
Oliver Schneider
24787195a1
serialize tuple enums with single element directly as the value instead of a sequence
2015-07-24 09:10:58 +02:00
Erick Tryzelaar
b1cb5379de
Add `#[serde(skip_serializing)] to skip serializing some fields
...
Closes #99
2015-07-23 08:07:49 -07:00
Erick Tryzelaar
b0512a4479
Fix deriving traits for fully generic types.
...
Closes #100
2015-07-23 07:25:27 -07:00
Erick Tryzelaar
e35603eb85
Fix serializing maps/sequences with no size hint
...
Closes #101
2015-07-22 10:44:43 -07:00
Erick Tryzelaar
8fa40fe7e1
Move json into it's own crate
...
Not everyone needs json, so no reason to force people to build
it.
2015-07-22 10:44:43 -07:00
Erick Tryzelaar
dbe2beacb0
Allow structs to be deserialized from sequences
...
This relies on the sequence to have the same ordering as the
struct field order.
2015-07-22 10:44:43 -07:00
Erick Tryzelaar
4dd7345568
Simplify result serialization and deserialization
2015-07-22 10:44:43 -07:00
Erick Tryzelaar
1751155a3a
Minor cleanup
2015-07-22 10:44:43 -07:00