Crate rdftk_iri

source ·
Expand description

iri This crate provides an IriExtra trait, Iri and IriRef types, and a Name type.

§Examples

The Iri type is a wrapper around the url::Url type, and as can be constructed in the same manner.

use rdftk_iri::Iri;
use std::str::FromStr;

let result = Iri::from_str(
    "https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top",
).unwrap();

The IriExtra trait provides a number of additional methods useful to the IRI as a namespace and namespaced-name identifier.

use rdftk_iri::{Iri, IriExtra as _, Name};
use std::str::FromStr;

let namespace = Iri::from_str(
    "https://example.org/ns/things#",
).unwrap();
assert!(namespace.looks_like_namespace());

let name = namespace.make_name(Name::from_str("ThisThing").unwrap()).unwrap();
assert_eq!(
    name.to_string(),
    "https://example.org/ns/things#ThisThing".to_string(),
);

assert_eq!(
    name.namespace(),
    Some(namespace),
);

assert_eq!(
    name.name(),
    Some(Name::from_str("ThisThing").unwrap()),
);

Structs§

  • This type represents the name component of an IRI used as a namespaced identifier.

Enums§

  • Denotes an error generated by the NameParser’s parse_str method.
  • This enum represents the different rules used to validate a string as a potential Name value.

Traits§

  • Additional, mainly constructor functions for the Iri type.

Functions§

  • Returns a new IRI with a well-known path of "genid" using the scheme and server components from base.

Type Aliases§

  • Errors reported while parsing a string into an IRI.
  • The common type for IRI values used throughout the RDFtk packages.
  • The reference-counted type wrapping an Iri.