pub trait MutableDataset: Dataset {
type MutationError: Error + 'static;
// Required methods
fn insert<TS, TP, TO, TG>(
&mut self,
s: TS,
p: TP,
o: TO,
g: GraphName<TG>,
) -> MdResult<Self, bool>
where TS: Term,
TP: Term,
TO: Term,
TG: Term;
fn remove<TS, TP, TO, TG>(
&mut self,
s: TS,
p: TP,
o: TO,
g: GraphName<TG>,
) -> MdResult<Self, bool>
where TS: Term,
TP: Term,
TO: Term,
TG: Term;
// Provided methods
fn insert_quad<T>(&mut self, quad: T) -> MdResult<Self, bool>
where T: Quad { ... }
fn remove_quad<T>(&mut self, quad: T) -> MdResult<Self, bool>
where T: Quad { ... }
fn insert_all<TS: QuadSource>(
&mut self,
src: TS,
) -> StreamResult<usize, TS::Error, <Self as MutableDataset>::MutationError> { ... }
fn remove_all<TS: QuadSource>(
&mut self,
src: TS,
) -> StreamResult<usize, TS::Error, <Self as MutableDataset>::MutationError> { ... }
fn remove_matching<S, P, O, G>(
&mut self,
ms: S,
mp: P,
mo: O,
mg: G,
) -> Result<usize, Self::MutationError>
where S: TermMatcher,
P: TermMatcher,
O: TermMatcher,
G: GraphNameMatcher,
Self::MutationError: From<Self::Error> { ... }
fn retain_matching<S, P, O, G>(
&mut self,
ms: S,
mp: P,
mo: O,
mg: G,
) -> Result<(), Self::MutationError>
where S: TermMatcher,
P: TermMatcher,
O: TermMatcher,
G: GraphNameMatcher,
Self::MutationError: From<Self::Error> { ... }
}
Expand description
Generic trait for mutable RDF datasets.
NB: the semantics of this trait allows a dataset to contain duplicate quads;
see also SetDataset
.
Required Associated Types§
Sourcetype MutationError: Error + 'static
type MutationError: Error + 'static
The error type that this dataset may raise during mutations.
Required Methods§
Sourcefn insert<TS, TP, TO, TG>(
&mut self,
s: TS,
p: TP,
o: TO,
g: GraphName<TG>,
) -> MdResult<Self, bool>
fn insert<TS, TP, TO, TG>( &mut self, s: TS, p: TP, o: TO, g: GraphName<TG>, ) -> MdResult<Self, bool>
Insert the given quad in this dataset.
§Return value
The bool
value returned in case of success is
not significant unless this dataset also implements SetDataset
.
If it does,
true
is returned iff the insertion actually changed the dataset.
In other words,
a return value of false
means that the dataset was not changed,
because the quad was already present in this SetDataset
.
See also MutableDataset::insert_quad
§Usage
let schema = Namespace::new("http://schema.org/").unwrap();
let s_name = schema.get("name").unwrap();
let default_graph: Option<&'static SimpleTerm<'static>> = None;
dataset.insert(&s_name, &rdf::type_, &rdf::Property, default_graph)?;
dataset.insert(&s_name, &rdfs::range, &xsd::string, default_graph)?;
dataset.insert(&s_name, &rdfs::comment, "The name of the item.", Some(&rdfs::comment))?;
Sourcefn remove<TS, TP, TO, TG>(
&mut self,
s: TS,
p: TP,
o: TO,
g: GraphName<TG>,
) -> MdResult<Self, bool>
fn remove<TS, TP, TO, TG>( &mut self, s: TS, p: TP, o: TO, g: GraphName<TG>, ) -> MdResult<Self, bool>
Remove the given quad from this dataset.
§Return value
The bool
value returned in case of success is
not significant unless this dataset also implements SetDataset
.
If it does,
true
is returned iff the removal actually changed the dataset.
In other words,
a return value of false
means that the dataset was not changed,
because the quad was already absent from this SetDataset
.
Provided Methods§
Sourcefn insert_quad<T>(&mut self, quad: T) -> MdResult<Self, bool>where
T: Quad,
fn insert_quad<T>(&mut self, quad: T) -> MdResult<Self, bool>where
T: Quad,
Insert in this graph the given quad.
NB: if you want to insert a quad q
while keeping its ownership,
you can still pass q.spog()
.
See also MutableDataset::insert
Sourcefn remove_quad<T>(&mut self, quad: T) -> MdResult<Self, bool>where
T: Quad,
fn remove_quad<T>(&mut self, quad: T) -> MdResult<Self, bool>where
T: Quad,
Remove from this graph a the given quad.
NB: if you want to remove a quad q
while keeping its ownership,
you can still pass q.spog()
.
See also MutableDataset::remove
Sourcefn insert_all<TS: QuadSource>(
&mut self,
src: TS,
) -> StreamResult<usize, TS::Error, <Self as MutableDataset>::MutationError>
fn insert_all<TS: QuadSource>( &mut self, src: TS, ) -> StreamResult<usize, TS::Error, <Self as MutableDataset>::MutationError>
Insert into this dataset all quads from the given source.
§Blank node scope
The blank nodes contained in the quad 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 dataset contains data from a file, and you are inserting data from a different file. In that case, you should first transform the quad source, in order to get fresh blank node identifiers.
§Return value
The usize
value returned in case of success is
not significant unless this dataset also implements SetDataset
.
If it does,
the number of quads that were actually inserted
(i.e. that were not already present in this SetDataset
)
is returned.
Sourcefn remove_all<TS: QuadSource>(
&mut self,
src: TS,
) -> StreamResult<usize, TS::Error, <Self as MutableDataset>::MutationError>
fn remove_all<TS: QuadSource>( &mut self, src: TS, ) -> StreamResult<usize, TS::Error, <Self as MutableDataset>::MutationError>
Remove from this dataset all quads from the given source.
§Return value
The usize
value returned in case of success is
not significant unless this dataset also implements SetDataset
.
If it does,
the number of quads that were actually removed
(i.e. that were not already absent from this SetDataset
)
is returned.
Sourcefn remove_matching<S, P, O, G>(
&mut self,
ms: S,
mp: P,
mo: O,
mg: G,
) -> Result<usize, Self::MutationError>where
S: TermMatcher,
P: TermMatcher,
O: TermMatcher,
G: GraphNameMatcher,
Self::MutationError: From<Self::Error>,
fn remove_matching<S, P, O, G>(
&mut self,
ms: S,
mp: P,
mo: O,
mg: G,
) -> Result<usize, Self::MutationError>where
S: TermMatcher,
P: TermMatcher,
O: TermMatcher,
G: GraphNameMatcher,
Self::MutationError: From<Self::Error>,
Remove all quads matching the given matchers.
§Return value
The usize
value returned in case of success is
not significant unless this dataset also implements SetDataset
.
If it does,
the number of quads that were actually removed
(i.e. that were not already absent from this SetDataset
)
is returned.
§Note to implementors
The default implementation is rather naive, and could be improved in specific implementations of the trait.
Sourcefn retain_matching<S, P, O, G>(
&mut self,
ms: S,
mp: P,
mo: O,
mg: G,
) -> Result<(), Self::MutationError>where
S: TermMatcher,
P: TermMatcher,
O: TermMatcher,
G: GraphNameMatcher,
Self::MutationError: From<Self::Error>,
fn retain_matching<S, P, O, G>(
&mut self,
ms: S,
mp: P,
mo: O,
mg: G,
) -> Result<(), Self::MutationError>where
S: TermMatcher,
P: TermMatcher,
O: TermMatcher,
G: GraphNameMatcher,
Self::MutationError: From<Self::Error>,
Keep only the quads matching the given matchers.
§Note to implementors
The default implementation is rather naive, and could be improved in specific implementations of the trait.
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.