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:
Serialize
andSerializeAttribute
use the same attributes with the same options asDeserialize
.SerializationGroup
use 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
DeserializationGroup
trait for a type. - Deserialize
- Derives the
Deserialize
trait for a type. - Serialization
Group - Derives the
SerializationGroup
trait for a type. - Serialize
- Derives the
Serialize
trait for a type. - Serialize
Attribute - Derives the
SerializeAttribute
trait for a type.