Commit Graph

118 Commits

Author SHA1 Message Date
Erick Tryzelaar 3a5aa00262 fix(codegen): Fix clippy cfg_attr 2016-02-12 20:21:52 -08:00
Joe Wilm 9985d2ebfc plugin(clippy) now relies on feature = "clippy"
Was previously nightly. This resulted in compilation error when the
clippy feature was not enabled because the clippy crate could not be
found.
2016-02-10 11:42:33 -08:00
Erick Tryzelaar 0224e212f9 feat(codegen): Allow containers to be renamed
Closes #218
2016-02-08 11:11:36 -08:00
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 5d4f9ce72b refactor(codegen): Add FieldsAttr::from_{field,variant} 2016-02-08 10:09:30 -08:00
Erick Tryzelaar 807224d231 refactor(codegen): Add ContainerAttrs::from_items 2016-02-08 10:09:18 -08:00
Erick Tryzelaar 0bd380ee23 chore(cleanup): Minor reorganization of attr.rs 2016-02-08 08:30:29 -08:00
Erick Tryzelaar a926cb62f0 chore(codegen): Clean up error handling 2016-02-07 20:36:24 -08:00
Erick Tryzelaar f8b3990571 feat(de): Rename deserialize_struct_key to deserialize_struct_field
This makes it more consistent with the naming style used throughout
the rest of serde.
2016-02-05 17:27:18 -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
Joe Wilm 6d25fc9dbb feat(de): Support struct key hinting
Formats that do not provide type hints in the serialized format
(bincode, redis) rely on hinting in the deserializer. Struct key hinting
was not previously supported. This was not an issue in the past because
bincode serializes structs as a keyless sequence of values. However,
redis data is stored (key, value, key, value, ...), and the keys must be
deserialized to properly create a struct.

The default implementation of `visit_struct_key` is simply `visit` since
that was the previous method called in codegen.
2016-01-28 08:38:07 -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
Erick Tryzelaar 939e1540d4 Merge pull request #205 from JohnHeitmann/default-typo
Remove extraneous flag
2016-01-18 09:11:14 -08:00
Erick Tryzelaar 1ced6db73e Merge remote-tracking branch 'remotes/origin/v0.6.x' 2016-01-16 15:08:06 -08:00
Erick Tryzelaar 979a4bcd88 feat(errors): Don't panic if annotating a non-struct/enum
This also improves the error spans when there's an internal
error.

Closes #206.
2016-01-16 14:51:11 -08:00
John Heitmann bba21f99fe Remove extraneous flag 2016-01-11 17:51:07 -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 59285f627b Merge branch 'v0.6.x'
# Conflicts:
#	serde_codegen/Cargo.toml
2016-01-10 11:54:46 -08:00
Erick Tryzelaar 072ff149f5 fix(rustup): Update to latest rust; silence some warnings 2015-12-24 12:12:03 -05:00
Erick Tryzelaar b858cd9e18 Merge remote-tracking branch 'remotes/origin/v0.6.x'
# Conflicts:
#	serde_codegen/Cargo.toml
2015-11-28 21:16:51 -08:00
Erick Tryzelaar 966b104d48 fix(rustup): nightly rust moved Registry into rustc_plugin 2015-11-28 20:09:54 -08:00
Erick Tryzelaar 59e0d5e081 fix(warning): #[automatically_derived] was removed 2015-11-28 20:09:31 -08:00
Erick Tryzelaar f474c57881 Merge branch 'v0.6.x' 2015-11-02 20:39:32 -08:00
Erick Tryzelaar 7521db7b0b fix(crates): Bump aster and syntex_syntax 2015-11-01 13:24:26 -08:00
Oliver Schneider 56c42a907f fix(#151): renaming Deserializer::visit_* to Deserializer::deserialize_* 2015-10-20 09:30:15 +02:00
Erick Tryzelaar f872b3fb4b fix(cargo): Update aster, quasi, and syntex 2015-10-17 19:44:07 -07:00
Erick Tryzelaar ddc33ee747 cleanup(whitespace): Fix some whitespace issues 2015-10-14 08:52:25 -07:00
Oliver Schneider 1c88856fc8 $value_expr starting with a & took address of resulting bool 2015-10-12 11:04:50 +02: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 c68ab508c0 refactor(codegen): Simplify parsing attributes 2015-09-07 16:58:52 -07:00
Erick Tryzelaar 42069ca669 Refactor tests to not use serde_json 2015-08-29 17:29:42 -07:00
Sebastian Thiel 784cfcd49e Use fully qualified Result type
If that is not the case, the generated code might attempt to use a
custom `Result` type with incompatible type parameters.
2015-08-08 12:33:29 +02: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 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 6cbb72decf Inlne the visit_seq method 2015-07-31 07:22:13 -07:00
Erick Tryzelaar 0348a3914d Pass variant index to visit_enum_simple 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 24787195a1 serialize tuple enums with single element directly as the value instead of a sequence 2015-07-24 09:10:58 +02:00