Crates.io | xsd-types |
lib.rs | xsd-types |
version | 0.9.6 |
source | src |
created_at | 2022-02-24 09:12:43.69976 |
updated_at | 2024-09-18 12:24:23.523231 |
description | XSD data types. |
homepage | |
repository | https://github.com/timothee-haudebourg/xsd-types |
max_upload_size | |
id | 538370 |
size | 519,376 |
This crate aims at providing safe representations of XSD built-in data types.
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();
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!
Licensed under either of
at your option.
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.