pub enum Term {
Variable(String),
Iri(String),
PrefixedName(String, String),
Literal(String),
BlankNode(String),
}Expand description
A SPARQL term with resolved values.
Unlike crate::core::query::TermType which only carries the kind, this
enum carries the actual string content of the term.
Variants§
Variable(String)
Variable name without the leading ?.
Iri(String)
Fully-qualified IRI.
PrefixedName(String, String)
Prefixed name: (prefix_label, local_part).
Literal(String)
Literal lexical form, raw (including "..."@en or "..."^^xsd:integer).
BlankNode(String)
Blank node label without the leading _:.
Implementations§
Source§impl Term
impl Term
Sourcepub fn resolve(&self, prefix_map: &HashMap<String, String>) -> Self
pub fn resolve(&self, prefix_map: &HashMap<String, String>) -> Self
Resolve PrefixedName(p, l) → Iri(prefix_map[p] + l) if p is in
the map; otherwise return self unchanged.
Note: prefix_map keys are bare prefix labels (e.g., "foaf"), not
the colon-terminated form.
Sourcepub fn from_token(token: &str) -> Self
pub fn from_token(token: &str) -> Self
Parse a raw SPARQL token into a Term.
?nameor$name→Variable("name")<iri>→Iri("iri")_:label→BlankNode("label")"..."/'...'or starting with a digit / sign →Literal(raw)prefix:local→PrefixedName("prefix", "local")a(rdf:type shorthand) →PrefixedName("rdf", "type")- anything else →
Iri(token)(best-effort)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Term
impl<'de> Deserialize<'de> for Term
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Term
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnsafeUnpin for Term
impl UnwindSafe for Term
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more