-
-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add codegen expr magic for default, skip serializing, and alternative serializers #237
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`.
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.
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)) } ```
Opt-out of `num`s `default-features`
chore(git): Ignore swap files
fix(serde-rs#151): renaming Deserializer::visit_* to Deserializer::deserialize_*
Fix typos.
# Conflicts: # serde_codegen/Cargo.toml
feat(cargo): Quasi version to 0.3.9
# Conflicts: # serde_codegen/Cargo.toml
Have serde::de::Error require std::error::Error
Use SVG version of Travis CI build status badge
# Conflicts: # serde_codegen/Cargo.toml
* Added codegen for disallow_unknown * ... with new default to ignore unknown values during deserialization * Added ContainerAttrs
IgnoredAny was calling `deserializer.deserialize` directly which is guaranteed to Error for certain formats like redis and bincode. This adds a `deserialize_ignored_any` method to hint to such implementations.
feat(de): Support hinting for IgnoredAny
feat(ser): Add ser::Error trait; avoid panic when serializing Paths
…pathbuf Use deserializer.deserialize_string for PathBuf
This makes it more consistent with the naming style used throughout the rest of serde.
Rename struct key to field
This feature has never been used, and it's complicating the implementation of serde-rs#207. We could restore this functionality if there is ever interest in it. Closes serde-rs#211.
…d deserializing According to serde-rs#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 serde-rs#62. # Conflicts: # serde_codegen/src/attr.rs # serde_codegen/src/de.rs # serde_tests/tests/test_annotations.rs
Remove support for format-specific renames, replace with ser or de specific renames
Was previously nightly. This resulted in compilation error when the clippy feature was not enabled because the clippy crate could not be found.
plugin(clippy) now relies on feature = "clippy"
# Conflicts: # serde/src/de/mod.rs # serde_codegen/src/attr.rs # serde_codegen/src/de.rs # serde_codegen/src/lib.rs
# Conflicts: # serde_codegen/src/de.rs
This feature adds support for the default to be specified to be some expression (which unfortunately needs to be parsed from a string) without needing this value to have an implementation of `Default`, or for a new-type wrapper in order to provide an alternative implementation. This expression is run in a function, and therefore has no access to any of the internal state of the deserializer.
This allows end users to use an arbitrary expression to decide whether or not to serialize some field. This expression has access to all the fields in the struct, but none of the internal state of the Serialize implementation. For structs, serde implements this by creating a temporary trait and implementing the struct for it. For struct variants, the fields are copied by reference into a temporary struct first before implementing the temporary trait. This also fixes a bug where the serde_codegen wasn't making calls to Serializer::serialize_{tuple,struct}_variant{,_elt}.
This allows a field to be serialized with an expression instead of the default serializer. This simplifies serializing a struct or enum that contains an external type that doesn't implement `serde::Serialize`. This expression is passed a variable `serializer` that needs to be used to serialize the expression.
This allows a field to be deserialized with an expression instead of the default deserializer. This simplifies deserializing a struct or enum that contains an external type that doesn't implement `serde::Deserialize`. This expression is passed a variable `deserializer` that needs to be used to deserialize the expression.
arg, wrong branch. |
Pushed up on the right branch to #238. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative implementation of #214, #198, #208 and implements #90 and #216. This allows one to write:
cc @oli-obk, @target-san, @arcnmx