[−][src]Trait sophia::graph::MutableGraph
Generic trait for mutable RDF graphs.
NB: the semantics of this trait allows a graph to contain duplicate triples;
see also SetGraph
.
Associated Types
type MutationError: 'static + Error
The error type that this graph may raise during mutations.
Required methods
fn insert<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, Self::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, Self::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
Insert the given triple in this graph.
Return value
The bool
value returned in case of success is
not significant unless this graph also implements SetGraph
.
If it does,
true
is returned iff the insertion actually changed the graph.
In other words,
a return value of false
means that the graph was not changed,
because the triple was already present in this SetGraph
.
Usage
let schema = Namespace::new("http://schema.org/").unwrap(); let s_name = schema.get("name").unwrap(); graph.insert(&s_name, &rdf::type_, &rdf::Property)?; graph.insert(&s_name, &rdfs::range, &xsd::string)?;
fn remove<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, Self::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, Self::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
Remove the given triple from this graph.
Return value
The bool
value returned in case of success is
not significant unless this graph also implements SetGraph
.
If it does,
true
is returned iff the removal actually changed the graph.
In other words,
a return value of false
means that the graph was not changed,
because the triple was already absent from this SetGraph
.
Provided methods
fn insert_all<TS>(
&mut self,
src: TS
) -> Result<usize, StreamError<<TS as TripleSource>::Error, Self::MutationError>> where
TS: TripleSource,
&mut self,
src: TS
) -> Result<usize, StreamError<<TS as TripleSource>::Error, Self::MutationError>> where
TS: TripleSource,
Insert into this graph all triples from the given source.
Blank node scope
The blank nodes contained in the triple source will be inserted as is. If they happen to have the same identifier as blank nodes already present, they will be considered equal. This might not be what you want, especially if the graph contains data from a file, and you are inserting data from a different file. In that case, you should first transform the triple source, in order to get fresh blank node identifiers.
Return value
The usize
value returned in case of success is
not significant unless this graph also implements SetGraph
.
If it does,
the number of triples that were actually inserted
(i.e. that were not already present in this SetGraph
)
is returned.
fn remove_all<TS>(
&mut self,
src: TS
) -> Result<usize, StreamError<<TS as TripleSource>::Error, Self::MutationError>> where
TS: TripleSource,
&mut self,
src: TS
) -> Result<usize, StreamError<<TS as TripleSource>::Error, Self::MutationError>> where
TS: TripleSource,
Remove from this graph all triples from the given source.
Return value
The usize
value returned in case of success is
not significant unless this graph also implements SetGraph
.
If it does,
the number of triples that were actually removed
(i.e. that were not already absent from this SetGraph
)
is returned.
fn remove_matching<S, P, O>(
&'s mut self,
ms: &S,
mp: &P,
mo: &O
) -> Result<usize, Self::MutationError> where
O: TermMatcher + ?Sized,
P: TermMatcher + ?Sized,
S: TermMatcher + ?Sized,
<<Self::Triple as TripleStreamingMode>::UnsafeTriple as UnsafeTriple>::Term: Clone,
Self::Error: Into<Self::MutationError>,
&'s mut self,
ms: &S,
mp: &P,
mo: &O
) -> Result<usize, Self::MutationError> where
O: TermMatcher + ?Sized,
P: TermMatcher + ?Sized,
S: TermMatcher + ?Sized,
<<Self::Triple as TripleStreamingMode>::UnsafeTriple as UnsafeTriple>::Term: Clone,
Self::Error: Into<Self::MutationError>,
Remove all triples matching the given matchers.
Return value
The usize
value returned in case of success is
not significant unless this graph also implements SetGraph
.
If it does,
the number of triples that were actually removed
(i.e. that were not already absent from this SetGraph
)
is returned.
Note to implementors
The default implementation is rather naive, and could be improved in specific implementations of the trait.
fn retain_matching<S, P, O>(
&'s mut self,
ms: &S,
mp: &P,
mo: &O
) -> Result<(), Self::MutationError> where
O: TermMatcher + ?Sized,
P: TermMatcher + ?Sized,
S: TermMatcher + ?Sized,
<<Self::Triple as TripleStreamingMode>::UnsafeTriple as UnsafeTriple>::Term: Clone,
Self::Error: Into<Self::MutationError>,
&'s mut self,
ms: &S,
mp: &P,
mo: &O
) -> Result<(), Self::MutationError> where
O: TermMatcher + ?Sized,
P: TermMatcher + ?Sized,
S: TermMatcher + ?Sized,
<<Self::Triple as TripleStreamingMode>::UnsafeTriple as UnsafeTriple>::Term: Clone,
Self::Error: Into<Self::MutationError>,
Keep only the triples matching the given matchers.
Note to implementors
The default implementation is rather naive, and could be improved in specific implementations of the trait.
Implementations on Foreign Types
impl<T, BH> MutableGraph for HashSet<[T; 3], BH> where
BH: BuildHasher,
T: TTerm + CopyTerm + Eq + Hash,
[src]
BH: BuildHasher,
T: TTerm + CopyTerm + Eq + Hash,
type MutationError = Infallible
fn insert<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <HashSet<[T; 3], BH> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
[src]
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <HashSet<[T; 3], BH> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
fn remove<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <HashSet<[T; 3], BH> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
[src]
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <HashSet<[T; 3], BH> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
impl<T> MutableGraph for Vec<[T; 3]> where
T: TTerm + CopyTerm,
[src]
T: TTerm + CopyTerm,
type MutationError = Infallible
fn insert<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <Vec<[T; 3]> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
[src]
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <Vec<[T; 3]> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
fn remove<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <Vec<[T; 3]> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
[src]
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <Vec<[T; 3]> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
Implementors
impl<'_, D, E, T> MutableGraph for DatasetGraph<D, E, Option<&'_ T>> where
D: MutableDataset,
E: BorrowMut<D>,
T: TTerm + ?Sized,
[src]
D: MutableDataset,
E: BorrowMut<D>,
T: TTerm + ?Sized,
type MutationError = <D as MutableDataset>::MutationError
fn insert<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <DatasetGraph<D, E, Option<&'_ T>> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
[src]
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <DatasetGraph<D, E, Option<&'_ T>> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
fn remove<TS, TP, TO>(
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <DatasetGraph<D, E, Option<&'_ T>> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
[src]
&mut self,
s: &TS,
p: &TP,
o: &TO
) -> Result<bool, <DatasetGraph<D, E, Option<&'_ T>> as MutableGraph>::MutationError> where
TO: TTerm + ?Sized,
TP: TTerm + ?Sized,
TS: TTerm + ?Sized,
impl<I> MutableGraph for HashGraph<I> where
I: TermIndexMap,
I::Index: Hash,
<I::Factory as TermFactory>::TermData: 'static,
[src]
I: TermIndexMap,
I::Index: Hash,
<I::Factory as TermFactory>::TermData: 'static,
type MutationError = Infallible
fn insert<TS_: ?Sized, TP_: ?Sized, TO_: ?Sized>(
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
[src]
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
fn remove<TS_: ?Sized, TP_: ?Sized, TO_: ?Sized>(
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
[src]
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
impl<T> MutableGraph for OpsWrapper<T> where
T: IndexedGraph + Graph<Triple = ByTermRefs<Term<<T as IndexedGraph>::TermData>>>,
[src]
T: IndexedGraph + Graph<Triple = ByTermRefs<Term<<T as IndexedGraph>::TermData>>>,
type MutationError = Infallible
fn insert<TS_: ?Sized, TP_: ?Sized, TO_: ?Sized>(
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
[src]
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
fn remove<TS_: ?Sized, TP_: ?Sized, TO_: ?Sized>(
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
[src]
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
impl<T> MutableGraph for SpoWrapper<T> where
T: IndexedGraph + Graph<Triple = ByTermRefs<Term<<T as IndexedGraph>::TermData>>>,
[src]
T: IndexedGraph + Graph<Triple = ByTermRefs<Term<<T as IndexedGraph>::TermData>>>,
type MutationError = Infallible
fn insert<TS_: ?Sized, TP_: ?Sized, TO_: ?Sized>(
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
[src]
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
fn remove<TS_: ?Sized, TP_: ?Sized, TO_: ?Sized>(
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,
[src]
&mut self,
s: &TS_,
p: &TP_,
o: &TO_
) -> MGResult<Self, bool> where
TS_: TTerm,
TP_: TTerm,
TO_: TTerm,