Expand description
§XMLity Derive
This crate contains the proc-macros for XMLity, specifically the derive macros for Serialize, SerializeAttribute, Deserialize, SerializationGroup, and DeserializationGroup.
Each of these macros has its own documentation, which can be found by following the links above.
The attributes used by these macros are made to be compatible with their counterparts:
SerializeandSerializeAttributeuse the same attributes with the same options asDeserialize.SerializationGroupuse the same attributes with the same options asDeserializationGroup.
There are some attributes only used by either serialization or deserialization. These are highlighted in the documentation for each macro.
§Example
ⓘ
use xmlity_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[xelement(name = "name")]
struct Name(String);
#[derive(Serialize, Deserialize)]
#[xelement(name = "age")]
struct Age(u8);
#[derive(Serialize, Deserialize)]
#[xelement(name = "person")]
struct Person {
name: Name,
age: Age,
}The derive macros are re-exported by the xmlity crate in the derive feature, so you can use them directly from there without referring to [xmlity_derive].
Derive Macros§
- Deserialization
Group - Derives the
DeserializationGrouptrait for a type. - Deserialize
- Derives the
Deserializetrait for a type. - Serialization
Group - Derives the
SerializationGrouptrait for a type. - Serialize
- Derives the
Serializetrait for a type. - Serialize
Attribute - Derives the
SerializeAttributetrait for a type.