Crate xso

source ·
Expand description

§Core types, macros and traits for parsing structs from XML

This crate provides the facilities for parsing XML data into Rust structs, and vice versa. Think of it as an alternative1 to serde, more suited to XML.

To get started, use the FromXml and IntoXml derive macros on your struct. See in particular the documentation of FromXml for a full reference on the supported attributes.

XSO is an acronym for XML Stream(ed) Objects, referring to the main field of use of this library in parsing XML streams like specified in RFC 6120.


  1. Though it should be said that you can combine serde and this crate on the same struct, no problem with that! 

Modules§

  • Error types for parsing and serialisation.

Structs§

  • Text codec transforming text to binary using standard base64.
  • Text codec transforming text to binary by emitting it as colon-separated hex value.
  • Discard the value and do not emit a value.
  • Text codec which returns None instead of the empty string.
  • Codec for bytes of lowercase hexadecimal, with a fixed length N (in bytes).
  • Text preprocessor which returns the input unchanged.
  • Shim wrapper around String which refuses to parse if the string is empty
  • Text codec which does no transform.
  • Text preprocessor to remove all whitespace.
  • Text codec which trims whitespace at the beginning and the end of the text.

Enums§

Traits§

  • Trait for structs implementing FromXml with namespace = dyn.
  • Enumeration of possible dynamically determined namespaces.
  • Trait to support destructuring of child structs beyond what the extract(..) attribute can deliver.
  • Provide construction of a value from optional XML text data.
  • Provide construction of structs from XML (sub-)trees.
  • Convert XML text to a value.
  • Provide destruction of a value into optional XML text data.
  • Convert a struct into an XML tree.
  • Convert a value into XML text.
  • Represent a way to encode/decode text data into a Rust type.
  • Trait for preprocessing text data from XML.
  • Trait for fallible extension.

Derive Macros§

  • Make a struct fully dynamically namespaceable
  • Make a struct or enum parseable from XML
  • Make a struct or enum convertible into XML