pub trait Dataset {
    type Quad<'x>: Quad
       where Self: 'x;
    type Error: Error + 'static;

Show 17 methods // Required method fn quads(&self) -> DQuadSource<'_, Self>; // Provided methods fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G ) -> DQuadSource<'s, Self> 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) -> DTermSource<'_, Self> { ... } fn predicates(&self) -> DTermSource<'_, Self> { ... } fn objects(&self) -> DTermSource<'_, Self> { ... } fn graph_names(&self) -> DTermSource<'_, Self> { ... } fn iris(&self) -> DTermSource<'_, Self> { ... } fn blank_nodes(&self) -> DTermSource<'_, Self> { ... } fn literals(&self) -> DTermSource<'_, Self> { ... } fn quoted_triples<'s>(&'s self) -> DTermSource<'s, Self> where DTerm<'s, Self>: Clone { ... } fn variables(&self) -> DTermSource<'_, 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§

source

type Quad<'x>: Quad where Self: 'x

Determine the type of Quads that the methods of this dataset will yield.

source

type Error: Error + 'static

The error type that this dataset may raise.

Required Methods§

source

fn quads(&self) -> DQuadSource<'_, Self>

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 any

Provided Methods§

source

fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G ) -> DQuadSource<'s, Self>
where S: TermMatcher + 's, P: TermMatcher + 's, O: TermMatcher + 's, G: GraphNameMatcher + 's,

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());
}
source

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,

Return true if this dataset contains the given quad.

source

fn subjects(&self) -> DTermSource<'_, 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.

source

fn predicates(&self) -> DTermSource<'_, 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.

source

fn objects(&self) -> DTermSource<'_, 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.

source

fn graph_names(&self) -> DTermSource<'_, 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.

source

fn iris(&self) -> DTermSource<'_, 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.

source

fn blank_nodes(&self) -> DTermSource<'_, 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.

source

fn literals(&self) -> DTermSource<'_, 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.

source

fn quoted_triples<'s>(&'s self) -> DTermSource<'s, Self>
where DTerm<'s, Self>: Clone,

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.

source

fn variables(&self) -> DTermSource<'_, 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.

source

fn graph<T>(&self, graph_name: GraphName<T>) -> DatasetGraph<&Self, T>
where T: for<'x> Term<BorrowTerm<'x> = DTerm<'x, Self>> + 'static,

Borrows one of the graphs of this dataset

source

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,

Borrows mutably one of the graphs of this dataset

source

fn partial_union_graph<M>(&self, selector: M) -> PartialUnionGraph<&Self, M>

Borrows a graph that is the union of some of this dataset’s graphs

source

fn union_graph(&self) -> UnionGraph<&Self>

Borrows a graph that is the union of all this dataset’s graphs (default and named)

source

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)

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

fn quads(&self) -> DQuadSource<'_, Self>

source§

fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G ) -> DQuadSource<'s, Self>
where S: TermMatcher + 's, P: TermMatcher + 's, O: TermMatcher + 's, G: GraphNameMatcher + 's,

source§

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,

source§

fn subjects(&self) -> DTermSource<'_, Self>

source§

fn predicates(&self) -> DTermSource<'_, Self>

source§

fn objects(&self) -> DTermSource<'_, Self>

source§

fn graph_names(&self) -> DTermSource<'_, Self>

source§

fn iris(&self) -> DTermSource<'_, Self>

source§

fn blank_nodes(&self) -> DTermSource<'_, Self>

source§

fn literals(&self) -> DTermSource<'_, Self>

source§

fn quoted_triples<'s>(&'s self) -> DTermSource<'s, Self>
where DTerm<'s, Self>: Clone,

source§

fn variables(&self) -> DTermSource<'_, Self>

source§

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

source§

fn quads(&self) -> DQuadSource<'_, Self>

source§

fn quads_matching<'s, S, P, O, G>( &'s self, sm: S, pm: P, om: O, gm: G ) -> DQuadSource<'s, Self>
where S: TermMatcher + 's, P: TermMatcher + 's, O: TermMatcher + 's, G: GraphNameMatcher + 's,

source§

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,

source§

fn subjects(&self) -> DTermSource<'_, Self>

source§

fn predicates(&self) -> DTermSource<'_, Self>

source§

fn objects(&self) -> DTermSource<'_, Self>

source§

fn graph_names(&self) -> DTermSource<'_, Self>

source§

fn iris(&self) -> DTermSource<'_, Self>

source§

fn blank_nodes(&self) -> DTermSource<'_, Self>

source§

fn literals(&self) -> DTermSource<'_, Self>

source§

fn quoted_triples<'s>(&'s self) -> DTermSource<'s, Self>
where DTerm<'s, Self>: Clone,

source§

fn variables(&self) -> DTermSource<'_, Self>

source§

impl<Q: Quad> Dataset for [Q]

§

type Error = Infallible

§

type Quad<'x> = ([<<Q as Quad>::Term as Term>::BorrowTerm<'x>; 3], Option<<<Q as Quad>::Term as Term>::BorrowTerm<'x>>) where Self: 'x

source§

fn quads(&self) -> DQuadSource<'_, Self>

source§

impl<Q: Quad> Dataset for BTreeSet<Q>

NB: This is a straighforward and minimal implementation, not taking advantage of the order of terms to optimize Dataset::quads_matching nor other methods.

§

type Error = Infallible

§

type Quad<'x> = ([<<Q as Quad>::Term as Term>::BorrowTerm<'x>; 3], Option<<<Q as Quad>::Term as Term>::BorrowTerm<'x>>) where Self: 'x

source§

fn quads(&self) -> DQuadSource<'_, Self>

source§

impl<Q: Quad> Dataset for Vec<Q>

§

type Error = Infallible

§

type Quad<'x> = ([<<Q as Quad>::Term as Term>::BorrowTerm<'x>; 3], Option<<<Q as Quad>::Term as Term>::BorrowTerm<'x>>) where Self: 'x

source§

fn quads(&self) -> DQuadSource<'_, Self>

source§

impl<Q: Quad, S> Dataset for HashSet<Q, S>

§

type Error = Infallible

§

type Quad<'x> = ([<<Q as Quad>::Term as Term>::BorrowTerm<'x>; 3], Option<<<Q as Quad>::Term as Term>::BorrowTerm<'x>>) where Self: 'x

source§

fn quads(&self) -> DQuadSource<'_, Self>

Implementors§

source§

impl<T> Dataset for GraphAsDataset<T>
where T: Graph,

§

type Quad<'x> = ([<<T as Graph>::Triple<'x> as Triple>::Term; 3], Option<<<T as Graph>::Triple<'x> as Triple>::Term>) where Self: 'x

§

type Error = <T as Graph>::Error