35 releases

new 0.9.4 May 13, 2024
0.9.2 Mar 15, 2024
0.8.2 Oct 20, 2023
0.7.6 May 31, 2023
0.2.0 Feb 24, 2022

#4 in #datatype

Download history 140/week @ 2024-02-22 190/week @ 2024-02-29 55/week @ 2024-03-07 153/week @ 2024-03-14 35/week @ 2024-03-21 37/week @ 2024-03-28 93/week @ 2024-04-04 201/week @ 2024-04-11 11/week @ 2024-04-18 659/week @ 2024-04-25 32/week @ 2024-05-02 146/week @ 2024-05-09

863 downloads per month
Used in 9 crates (3 directly)

MIT/Apache

455KB
14K SLoC

XSD Types for Rust

CI Crate informations License Documentation

This crate aims at providing safe representations of XSD built-in data types.

Usage

For each XSD datatype, this library provides two families of types: one representing the lexical space of the datatype (see the lexical module), and one representing the value space of the datatype (see the value module).

For instance, assume we wish to store the lexical representation of an XSD decimal datatype value. We can use the lexical::Decimal type (or its owned variant, lexical::DecimalBuf)

let string = "3.141592653589793";

// Parse the lexical representation (lexical domain).
let lexical_repr = xsd_types::lexical::Decimal::new(string).unwrap();

// Interprets the lexical representation (value domain).
use xsd_types::lexical::LexicalFormOf;
let value_repr: xsd_types::Decimal = lexical_repr.try_as_value().unwrap();

Of course it is possible to parse the value directly into the value domain using FromStr:

let value_repr: xsd_types::Decimal = "3.141592653589793".parse().unwrap();

Any value

The Value type provides a simple way to represent any XSD value.

use xsd_types::{XSD_DATE, Datatype, Value};
let dt = Datatype::from_iri(XSD_DATE).unwrap();
let value: Value = dt.parse("1758-12-25").unwrap(); // Halley is back!

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6MB
~119K SLoC