Crate curie [] [src]

CURIEs: Compact URIs

CURIEs, defined by the W3C, are a compact way of representing a URI. A CURIE consists of an optional prefix and a reference, separated by a colon.

Example CURIEs:

  • "foaf:Person" -- Results in a URI in the foaf namespace.
  • ":Person" -- Results in a URI in the default namespace.
  • "Person" -- Results in a URI in the default namespace.

The last two examples rely upon there being a default mapping providing a default base URI.

See the specification for further details.

Usage

use curie::PrefixMapping;

// Initialize a prefix mapper.
let mut mapper = PrefixMapping::default();
mapper.add_prefix("foaf", "http://xmlns.com/foaf/0.1/");

// Set a default prefix
mapper.set_default("http://example.com/");

// Expand a CURIE and get back the full URI.
assert_eq!(mapper.expand("Entity"),
           Ok(String::from("http://example.com/Entity")));
assert_eq!(mapper.expand("foaf:Agent"),
           Ok(String::from("http://xmlns.com/foaf/0.1/Agent")));

Structs

PrefixMapping

Maps prefixes to base URIs and allows for the expansion of CURIEs (Compact URIs).

Enums

PrefixMappingError

Errors that might occur during CURIE expansion.