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§

source

type MutationError: Error + 'static

The error type that this dataset may raise during mutations.

Required Methods§

source

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,

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))?;
source

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,

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§

source

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

source

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

source

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.

source

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.

source

fn remove_matching<S, P, O, G>( &mut self, ms: S, mp: P, mo: O, mg: G ) -> Result<usize, Self::MutationError>

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.

source

fn retain_matching<S, P, O, G>( &mut self, ms: S, mp: P, mo: O, mg: G ) -> Result<(), Self::MutationError>

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> MutableDataset for BTreeSet<Gspo<T>>
where T: Term + FromTerm + Ord,

§

type MutationError = Infallible

source§

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,

source§

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,

source§

impl<T> MutableDataset for BTreeSet<Spog<T>>
where T: Term + FromTerm + Ord,

§

type MutationError = Infallible

source§

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,

source§

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,

source§

impl<T> MutableDataset for Vec<Gspo<T>>
where T: Term + FromTerm,

§

type MutationError = Infallible

source§

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,

source§

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,

source§

impl<T> MutableDataset for Vec<Spog<T>>
where T: Term + FromTerm,

§

type MutationError = Infallible

source§

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,

source§

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,

source§

impl<T, S> MutableDataset for HashSet<Gspo<T>, S>
where T: Term + Eq + FromTerm + Hash, S: BuildHasher + Default,

§

type MutationError = Infallible

source§

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,

source§

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,

source§

impl<T, S> MutableDataset for HashSet<Spog<T>, S>
where T: Term + Eq + FromTerm + Hash, S: BuildHasher + Default,

§

type MutationError = Infallible

source§

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,

source§

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,

source§

impl<T: MutableDataset + ?Sized> MutableDataset for &mut T

§

type MutationError = <T as MutableDataset>::MutationError

source§

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,

source§

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,

source§

fn insert_all<TS: QuadSource>( &mut self, src: TS ) -> StreamResult<usize, TS::Error, Self::MutationError>

source§

fn remove_all<TS: QuadSource>( &mut self, src: TS ) -> StreamResult<usize, TS::Error, Self::MutationError>

source§

fn remove_matching<S, P, O, G>( &mut self, ms: S, mp: P, mo: O, mg: G ) -> Result<usize, Self::MutationError>

source§

fn retain_matching<S, P, O, G>( &mut self, ms: S, mp: P, mo: O, mg: G ) -> Result<(), Self::MutationError>

Implementors§