1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! RDF integration functionality
//!
//! This module provides RDF-specific scalars, SPARQL mapping, and RDF store integration.
// Re-export RDF functionality
pub use crate::mapping::*;
pub use crate::rdf_scalars::*;
/// RDF components
pub mod components {
/// Individual RDF components
/// RDF scalar types
pub mod scalars {
pub use crate::rdf_scalars::*;
}
/// GraphQL to SPARQL mapping
pub mod mapping {
pub use crate::mapping::*;
}
}
/// Common RDF utilities and helpers
pub mod utils {
/// Validate IRI format
pub fn is_valid_iri(iri: &str) -> bool {
crate::rdf_scalars::IRI::new(iri.to_string()).is_ok()
}
/// Create a prefixed name from namespace and local name
pub fn create_prefixed_name(namespace: &str, local: &str) -> String {
format!("{namespace}{local}")
}
/// Extract namespace from IRI
pub fn extract_namespace(iri: &str) -> Option<String> {
if let Some(pos) = iri.rfind('/') {
Some(iri[..pos + 1].to_string())
} else {
iri.rfind('#').map(|pos| iri[..pos + 1].to_string())
}
}
/// Extract local name from IRI
pub fn extract_local_name(iri: &str) -> Option<String> {
if let Some(pos) = iri.rfind('/') {
Some(iri[pos + 1..].to_string())
} else {
iri.rfind('#').map(|pos| iri[pos + 1..].to_string())
}
}
}