pub struct Curie<'c> { /* fields omitted */ }
A prefix and reference, already parsed into separate components.
When parsing a document, the components of the compact URI will already
have been parsed and we can avoid storing a string of the full compact
URI and having to do that work again when expanding the compact URI.
The 'c
lifetime parameter will typically be the lifetime of the body
of text which is being parsed and contains the compact URIs.
let c = Curie::new(Some("foaf"), "Person");
Expanding a Curie
requires the use of a properly initialized
PrefixMapping
.
let mut mapper = PrefixMapping::default();
mapper.add_prefix("foaf", "http://xmlns.com/foaf/0.1/").unwrap();
let curie = Curie::new(Some("foaf"), "Agent");
assert_eq!(mapper.expand_curie(&curie),
Ok(String::from("http://xmlns.com/foaf/0.1/Agent")));
Curie
implements the Debug
and Display
traits, so it integrates with
the Rust standard library facilities.
let curie = Curie::new(Some("foaf"), "Agent");
assert_eq!("foaf:Agent", format!("{}", curie));
Construct a Curie
from a prefix and reference.
Formats the value using the given formatter. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more