π zvariant 5.5.0
·
688 commits
to main
since this release
- ποΈ Ensure empty array is (de)serialized the same way as unit type.
- β¨ Add as_value module. This new module provides API that can be used with
serde::{Serialize::Deserialize}derives to (de)serialize a value as aValue(variant type). This is espcially useful for (de)serialization of structs as a dictionary (a{sv}). - ποΈ Deprecate SerializeDict & DeserializeDict macro. Now that user can directly use
serde::{Serialize, Deserialize}for dict encoding of a struct, we don't need these anymore. - π Move SerializeValue & DeserializeValue into as_value & rename. These types belong in
as_valuemodule and given the context, we can just name themSerializeandDeserialize. We still provide type aliases to not break the API. - π Improve
Strdocs. - ποΈ Correctly handle identifier de for gvariant. We basically just need to do it exactly the same way as we do for the D-Bus format.
- ποΈ More robust deserialization of variants. Our deserializers rely on a specific behavior from the Value's Deserialize impls, and that fails when Value is being deserialized in a generic way (through deserialize_any or deserialize_ignored_any) and we end up with overflowing the stack. This happens for example when ignoring unknown fields/entries. Unfortunately, in case of GVariant we now no longer error out if a null byte is missing in a string type. You can blame Allison Lortie for removing the null-termination from a signature only when it is encoded in a variant but not otherwise. :)
- β¨ Allow structs to be serialized as dictionaries.
- β¨ zb,zn,Implement Borrow for Owned* types. Implementing
Borrowmakes things such as usingOwned*types as keys easier, and it was more-or-less designed for this type of scenario anyway. Although it comes with some stringent requirements (i.e. traits implemented on the owned type need to have identical behavior to the borrowed type), all of these types are already rather thin wrappers to begin with. - β Drop
static_assertionsdep. - π fix wrong lifetime when creating a Value from &Vec and &[]. When creating a Value from a borrowed vec or slice using Value's From implementation, the compiler would wrongfully assume, that the created value has the same lifetime, even though the input gets cloned when creating the Array struct. This commit makes the impl assign a new lifetime to the cloned value.
- β¨ Implement rename/rename_all when deriving Value/OwnedValue. Previously, setting these values would not apply to implementations of From and TryFrom when converting between a type and Value/OwnedValue. This change makes it so using rename or rename_all will apply to these traits. #320
- β¨
*Valuederive macros:- Support string encoding for enums.
- Support enum variants without explicit values.
- π Prefix a local variable w/
__so it doesn't conflict w/ fields. ..in the struct derivingDeserializeDict. #1252.