pub enum PathExpr {
Iri(String),
Inverse(Box<PathExpr>),
Sequence(Box<PathExpr>, Box<PathExpr>),
Alternative(Box<PathExpr>, Box<PathExpr>),
ZeroOrMore(Box<PathExpr>),
OneOrMore(Box<PathExpr>),
ZeroOrOne(Box<PathExpr>),
NegatedSet(Vec<String>),
}Expand description
A SPARQL property path expression.
Represents the full set of SPARQL 1.1 property path operators, enabling in-memory construction, analysis, and serialisation without requiring a triple store.
Variants§
Iri(String)
A single IRI step.
Inverse(Box<PathExpr>)
Inverse path: ^p.
Sequence(Box<PathExpr>, Box<PathExpr>)
Sequence: p/q.
Alternative(Box<PathExpr>, Box<PathExpr>)
Alternative: p|q.
ZeroOrMore(Box<PathExpr>)
Zero-or-more: p*.
OneOrMore(Box<PathExpr>)
One-or-more: p+.
ZeroOrOne(Box<PathExpr>)
Zero-or-one: p?.
NegatedSet(Vec<String>)
Negated property set: !(p|q).
Implementations§
Source§impl PathExpr
impl PathExpr
Sourcepub fn sequence(left: PathExpr, right: PathExpr) -> Self
pub fn sequence(left: PathExpr, right: PathExpr) -> Self
Create a sequence path expression (p/q).
Sourcepub fn alternative(left: PathExpr, right: PathExpr) -> Self
pub fn alternative(left: PathExpr, right: PathExpr) -> Self
Create an alternative path expression (p|q).
Sourcepub fn zero_or_more(inner: PathExpr) -> Self
pub fn zero_or_more(inner: PathExpr) -> Self
Create a zero-or-more repetition path expression (p*).
Sourcepub fn one_or_more(inner: PathExpr) -> Self
pub fn one_or_more(inner: PathExpr) -> Self
Create a one-or-more repetition path expression (p+).
Sourcepub fn zero_or_one(inner: PathExpr) -> Self
pub fn zero_or_one(inner: PathExpr) -> Self
Create a zero-or-one path expression (p?).
Sourcepub fn negated_set(iris: &[&str]) -> Self
pub fn negated_set(iris: &[&str]) -> Self
Create a negated property set path expression (!(p|q|...)).
Accepts a slice of IRI strings.
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
Returns the nesting depth / complexity of the path expression.
A single IRI or negated set has depth 1. Each wrapping operator adds 1.
Sourcepub fn iris(&self) -> Vec<String>
pub fn iris(&self) -> Vec<String>
Returns all unique IRIs referenced in the path expression, in sorted order.
Sourcepub fn can_match_zero(&self) -> bool
pub fn can_match_zero(&self) -> bool
Returns true if this path expression can match zero steps (i.e., is nullable).
*and?operators are always nullable.+is nullable iff its inner expression is nullable (it cannot be nullable unless inner is, butp+itself requires ≥1 match).- Sequences are nullable only if both arms are nullable.
- Alternatives are nullable if either arm is nullable.
- Plain IRIs and negated sets are not nullable.
- Inverse is nullable iff its inner is nullable.
Sourcepub fn to_sparql(&self) -> String
pub fn to_sparql(&self) -> String
Converts the path expression to its SPARQL 1.1 string representation.
Parentheses are inserted to make operator precedence explicit.
Sourcepub fn is_simple_iri(&self) -> bool
pub fn is_simple_iri(&self) -> bool
Returns true if the path is a plain IRI step (no operators).
Trait Implementations§
impl StructuralPartialEq for PathExpr
Auto Trait Implementations§
impl Freeze for PathExpr
impl RefUnwindSafe for PathExpr
impl Send for PathExpr
impl Sync for PathExpr
impl Unpin for PathExpr
impl UnsafeUnpin for PathExpr
impl UnwindSafe for PathExpr
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.