Crate xmlity_derive

Source
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:

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§

DeserializationGroup
Derives the DeserializationGroup trait for a type.
Deserialize
Derives the Deserialize trait for a type.
SerializationGroup
Derives the SerializationGroup trait for a type.
Serialize
Derives the Serialize trait for a type.
SerializeAttribute
Derives the SerializeAttribute trait for a type.