1use iri_rs::{Iri, iri};
9
10pub mod quad;
12mod triples;
13
14pub use quad::*;
15pub use triples::*;
16
17pub const RDF_TYPE: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
19pub const RDF_FIRST: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#first");
21pub const RDF_REST: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest");
23pub const RDF_VALUE: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#value");
25pub const RDF_DIRECTION: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#direction");
27pub const RDF_JSON: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON");
29pub const RDF_NIL: Iri<&'static str> = iri!("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
31
32pub const XSD_BOOLEAN: Iri<&'static str> = iri!("http://www.w3.org/2001/XMLSchema#boolean");
34pub const XSD_INTEGER: Iri<&'static str> = iri!("http://www.w3.org/2001/XMLSchema#integer");
36pub const XSD_DOUBLE: Iri<&'static str> = iri!("http://www.w3.org/2001/XMLSchema#double");
38pub const XSD_STRING: Iri<&'static str> = iri!("http://www.w3.org/2001/XMLSchema#string");
40
41#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
46pub enum RdfDirection {
47 I18nDatatype,
50
51 CompoundLiteral,
53}
54
55#[derive(Debug, Clone, thiserror::Error)]
56#[error("invalid RDF direction: {0}")]
57pub struct InvalidRdfDirection(pub String);
59
60impl std::str::FromStr for RdfDirection {
61 type Err = InvalidRdfDirection;
62
63 fn from_str(s: &str) -> Result<Self, Self::Err> {
64 match s {
65 "i18n-datatype" => Ok(Self::I18nDatatype),
66 "compound-literal" => Ok(Self::CompoundLiteral),
67 _ => Err(InvalidRdfDirection(s.to_string())),
68 }
69 }
70}
71
72impl<'a> TryFrom<&'a str> for RdfDirection {
73 type Error = InvalidRdfDirection;
74
75 fn try_from(value: &'a str) -> Result<Self, Self::Error> {
76 value.parse()
77 }
78}