rdf_types/
lib.rs

1//! The [Resource Description Framework (RDF)][rdf] is a very simple graph data
2//! model defined by the [World Wide Web Consortium (W3C)][w3c] to represent
3//! arbitrary pieces of information, primarily intended for the web. Nodes of
4//! the graph are called *resources*, and resources are connected together using
5//! *relations*, which are resources themselves.
6//!
7//! This is a utility library providing common types, data-structures, traits,
8//! constants and macro definitions to deal with RDF data:
9//! - IRIs (through the `iref` crate), blank node identifiers and literals to
10//!   represent resources in their lexical form as *terms*;
11//! - Triples and quads;
12//! - Interpretations projecting resources from the lexical domain to the value
13//!   domain;
14//! - Graphs and datasets representing collections of interpreted triples/quads.
15//!
16//! [rdf]: <https://w3c.github.io/rdf-primer/spec/>
17//! [w3c]: <https://www.w3.org/>
18#![recursion_limit = "1024"]
19
20#[doc(hidden)]
21pub use iref;
22
23#[doc(hidden)]
24pub use static_iref;
25
26mod blankid;
27mod display;
28mod grdf;
29mod literal;
30mod r#macro;
31mod quad;
32mod schema;
33mod term;
34mod triple;
35
36pub use blankid::*;
37pub use display::*;
38pub use grdf::*;
39pub use literal::*;
40pub use quad::*;
41pub use schema::*;
42pub use term::*;
43pub use triple::*;
44
45pub mod dataset;
46pub mod generator;
47pub mod interpretation;
48pub mod pattern;
49pub mod utils;
50pub mod vocabulary;
51
52pub use dataset::Dataset;
53pub use generator::Generator;
54pub use interpretation::{Interpretation, InterpretationMut};
55pub use iref::{Iri, IriBuf};
56pub use vocabulary::{Vocabulary, VocabularyMut};
57
58pub const XSD_STRING: &Iri = static_iref::iri!("http://www.w3.org/2001/XMLSchema#string");
59
60/// IRI type that may be <http://www.w3.org/2001/XMLSchema#string>.
61///
62/// This is used upon formatting RDF literals to omit the type when it is not
63/// required (because it is implicitly `xsd:string`).
64pub trait IsXsdStringIri {
65	/// Checks if this IRI is <http://www.w3.org/2001/XMLSchema#string>.
66	fn is_xsd_string_iri(&self) -> bool;
67}
68
69impl IsXsdStringIri for IriBuf {
70	fn is_xsd_string_iri(&self) -> bool {
71		self == XSD_STRING
72	}
73}
74
75impl IsXsdStringIri for Iri {
76	fn is_xsd_string_iri(&self) -> bool {
77		self == XSD_STRING
78	}
79}