rudof_rdf/rdf_core/vocabs/
mod.rs1use iri_s::IriS;
8use std::sync::OnceLock;
9
10mod rdf;
11mod rdfs;
12mod shacl;
13mod shacl_node_expression;
14mod xsd;
15
16pub use rdf::RdfVocab;
17pub use rdfs::RdfsVocab;
18pub use shacl::ShaclVocab;
19pub use shacl_node_expression::ShaclNodeExprVocab;
20pub use xsd::XsdVocab;
21
22#[macro_export]
23macro_rules! vocab_term {
24 ($voc:ident, $name:ident, $suffix:literal) => {
25 impl $voc {
26 pub const $name: &'static str = const_format::concatcp!($voc::BASE, $suffix);
27
28 paste::paste! {
29 pub fn [<$name:lower>]() -> &'static iri_s::IriS {
30 static IRI: std::sync::OnceLock<iri_s::IriS> = std::sync::OnceLock::new();
31 IRI.get_or_init(|| iri_s::IriS::new_unchecked(Self::$name))
32 }
33 }
34 }
35 };
36}
37
38pub trait RdfVocabulary {
39 const BASE: &'static str;
40
41 fn base_iri() -> &'static IriS {
42 static IRI: OnceLock<IriS> = OnceLock::new();
43 IRI.get_or_init(|| IriS::new_unchecked(Self::BASE))
44 }
45}