Crate xso_proc

source ·
Expand description

§Macros for parsing XML into Rust structs, and vice versa

If you are a user of xso_proc or xso, please return to xso for more information. The documentation of xso_proc is geared toward developers of …_macros and …_core.

You have been warned.

§How the derive macros work

The processing is roughly grouped in the following stages:

  1. syn is used to parse the incoming TokenStream into a syn::Item. Based on that, the decision is made whether a struct or an enum is being derived on.

  2. Depending on the item type (enum vs. struct), a [ItemDef] object is created which implements that item. The actual implementations reside in [crate::structs] and [crate::enums] (respectively).

    1. The [crate::meta::XmlCompoundMeta] type is used to convert the raw token streams from the #[xml(..)] attributes into structs/enums for easier handling.

      That stage only does syntax checks, no (or just little) semantics. This separation of concerns helps with simplifying the code both in meta and the following modules.

    2. Enum variants and structs are processed using [crate::compound::Compound], their fields being converted from [crate::meta::XmlFieldMeta] to [crate::field::FieldDef]. For enums, additional processing on the enum itself takes place in [crate::enums]. Likewise there’s special handling for structs in [crate::structs].

    3. If any wrapping was declared, the resulting ItemDef is wrapped using [crate::wrapped].

  3. After all data has been structured, action is taken depending on the specific derive macro which has been invoked.

Derive Macros§