pub trait Dataset {
type Quad<'x>: Quad
where Self: 'x;
type Error: Error + Send + Sync + 'static;
Show 17 methods
// Required method
fn quads(&self) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_;
// Provided methods
fn quads_matching<'s, S, P, O, G>(
&'s self,
sm: S,
pm: P,
om: O,
gm: G,
) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
where S: TermMatcher + 's,
P: TermMatcher + 's,
O: TermMatcher + 's,
G: GraphNameMatcher + 's { ... }
fn contains<TS, TP, TO, TG>(
&self,
s: TS,
p: TP,
o: TO,
g: GraphName<TG>,
) -> DResult<Self, bool>
where TS: Term,
TP: Term,
TO: Term,
TG: Term { ... }
fn subjects(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn predicates(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn objects(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn graph_names(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn iris(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn blank_nodes(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn literals(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn quoted_triples<'s>(
&'s self,
) -> Box<dyn Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_>
where DTerm<'s, Self>: Clone { ... }
fn variables(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_ { ... }
fn graph<T>(&self, graph_name: GraphName<T>) -> DatasetGraph<&Self, T>
where T: for<'x> Term<BorrowTerm<'x> = DTerm<'x, Self>> + 'static { ... }
fn graph_mut<T>(
&mut self,
graph_name: GraphName<T>,
) -> DatasetGraph<&mut Self, T>
where T: for<'x> Term<BorrowTerm<'x> = DTerm<'x, Self>> + 'static { ... }
fn partial_union_graph<M>(&self, selector: M) -> PartialUnionGraph<&Self, M>
where M: GraphNameMatcher + Copy { ... }
fn union_graph(&self) -> UnionGraph<&Self> { ... }
fn into_union_graph(self) -> UnionGraph<Self>
where Self: Sized { ... }
}Expand description
Generic trait for RDF datasets.
For convenience, this trait is implemented by standard collections of quads.
NB: the semantics of this trait allows a dataset to contain duplicate quads;
see also SetDataset.
Required Associated Types§
Required Methods§
Sourcefn quads(&self) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
fn quads(&self) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
An iterator visiting all quads of this dataset in arbitrary order.
This iterator is fallible:
its items are Results,
an error may occur at any time during the iteration.
§Examples
The result of this method is an iterator,
so it can be used in a for loop:
for q in dataset.quads() {
let q = q?; // rethrow error if any
// do something with q
}Another way is to use the specific methods provided by QuadSource,
for example:
dataset.quads().for_each_quad(|q| {
// do something with q
})?; // rethrow error if anyProvided Methods§
Sourcefn quads_matching<'s, S, P, O, G>(
&'s self,
sm: S,
pm: P,
om: O,
gm: G,
) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G, ) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
An iterator visiting all quads matching the given subject, predicate and object.
See crate::term::matcher
See also quads.
§Usage
Typical implementations of TermMatcher include arrays/slices of Terms,
closure accepting a SimpleTerm, or the special matcher Any.
let s = Namespace::new("http://schema.org/")?;
let city = s.get("City")?;
let country = s.get("Country")?;
for q in dataset.quads_matching(Any, [&rdf::type_], [city, country], Any) {
println!("{:?} was found", q?.s());
}Here is another example using a closure as a TermMatcher.
use sophia_api::term::matcher::Any;
for q in dataset.quads_matching(
Any,
[&rdfs::label],
|t: SimpleTerm| t.lexical_form().map(|v| v.contains("needle")).unwrap_or(false),
Any,
) {
println!("{:?} was found", q?.s());
}Sourcefn contains<TS, TP, TO, TG>(
&self,
s: TS,
p: TP,
o: TO,
g: GraphName<TG>,
) -> DResult<Self, bool>
fn contains<TS, TP, TO, TG>( &self, s: TS, p: TP, o: TO, g: GraphName<TG>, ) -> DResult<Self, bool>
Return true if this dataset contains the given quad.
Sourcefn subjects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn subjects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the terms used as subject in this Dataset.
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn predicates(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn predicates( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the terms used as predicate in this Dataset.
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn objects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn objects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the terms used as object in this Dataset.
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn graph_names(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn graph_names( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the terms used as graph name in this Dataset.
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn iris(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn iris(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the IRIs used in this Dataset (including those used inside quoted quads, if any).
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn blank_nodes(
&self,
) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn blank_nodes( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the blank nodes used in this Dataset (including those used inside quoted quads, if any).
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn literals(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn literals(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the literals used in this Dataset (including those used inside quoted quads, if any).
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn quoted_triples<'s>(
&'s self,
) -> Box<dyn Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_>
fn quoted_triples<'s>( &'s self, ) -> Box<dyn Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_>
Build a fallible iterator of all the quoted triples used in this Dataset (including those used inside quoted triples, if any).
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn variables(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn variables(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Build a fallible iterator of all the variables used in this Dataset (including those used inside quoted quads, if any).
NB: implementations SHOULD avoid yielding the same term multiple times, but MAY do so. Users MUST therefore be prepared to deal with duplicates.
Sourcefn graph<T>(&self, graph_name: GraphName<T>) -> DatasetGraph<&Self, T>
fn graph<T>(&self, graph_name: GraphName<T>) -> DatasetGraph<&Self, T>
Borrows one of the graphs of this dataset
Sourcefn graph_mut<T>(
&mut self,
graph_name: GraphName<T>,
) -> DatasetGraph<&mut Self, T>
fn graph_mut<T>( &mut self, graph_name: GraphName<T>, ) -> DatasetGraph<&mut Self, T>
Borrows mutably one of the graphs of this dataset
Sourcefn partial_union_graph<M>(&self, selector: M) -> PartialUnionGraph<&Self, M>where
M: GraphNameMatcher + Copy,
fn partial_union_graph<M>(&self, selector: M) -> PartialUnionGraph<&Self, M>where
M: GraphNameMatcher + Copy,
Borrows a graph that is the union of some of this dataset’s graphs
Sourcefn union_graph(&self) -> UnionGraph<&Self>
fn union_graph(&self) -> UnionGraph<&Self>
Borrows a graph that is the union of all this dataset’s graphs (default and named)
Sourcefn into_union_graph(self) -> UnionGraph<Self>where
Self: Sized,
fn into_union_graph(self) -> UnionGraph<Self>where
Self: Sized,
Convert into a graph that is the union of all this dataset’s graphs (default and named)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a, T: Dataset + ?Sized> Dataset for &'a T
impl<'a, T: Dataset + ?Sized> Dataset for &'a T
type Quad<'x> = <T as Dataset>::Quad<'x> where Self: 'x
type Error = <T as Dataset>::Error
fn quads(&self) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G, ) -> impl Iterator<Item = DResult<Self, Self::Quad<'s>>> + 's
fn contains<TS, TP, TO, TG>( &self, s: TS, p: TP, o: TO, g: GraphName<TG>, ) -> DResult<Self, bool>
fn subjects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn predicates( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn objects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn graph_names( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn iris(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn blank_nodes( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn literals(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn quoted_triples<'s>( &'s self, ) -> Box<dyn Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_>
fn variables(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Source§impl<'a, T: Dataset + ?Sized> Dataset for &'a mut T
impl<'a, T: Dataset + ?Sized> Dataset for &'a mut T
type Quad<'x> = <T as Dataset>::Quad<'x> where Self: 'x
type Error = <T as Dataset>::Error
fn quads(&self) -> impl Iterator<Item = DResult<Self, Self::Quad<'_>>> + '_
fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G, ) -> impl Iterator<Item = DResult<Self, Self::Quad<'s>>> + 's
fn contains<TS, TP, TO, TG>( &self, s: TS, p: TP, o: TO, g: GraphName<TG>, ) -> DResult<Self, bool>
fn subjects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn predicates( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn objects(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn graph_names( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn iris(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn blank_nodes( &self, ) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn literals(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
fn quoted_triples<'s>( &'s self, ) -> Box<dyn Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_>
fn variables(&self) -> impl Iterator<Item = DResult<Self, DTerm<'_, Self>>> + '_
Source§impl<Q: Quad> Dataset for BTreeSet<Q>
NB: This is a straightforward and minimal implementation,
not taking advantage of the order of terms to optimize Dataset::quads_matching
nor other methods.
impl<Q: Quad> Dataset for BTreeSet<Q>
NB: This is a straightforward and minimal implementation,
not taking advantage of the order of terms to optimize Dataset::quads_matching
nor other methods.