[][src]Trait sophia::dataset::MutableDataset

pub trait MutableDataset: Dataset {
    type MutationError: 'static + Error;
    fn insert<TS, TP, TO, TG>(
        &mut self,
        s: &TS,
        p: &TP,
        o: &TO,
        g: Option<&TG>
    ) -> Result<bool, Self::MutationError>
    where
        TG: TTerm + ?Sized,
        TO: TTerm + ?Sized,
        TP: TTerm + ?Sized,
        TS: TTerm + ?Sized
;
fn remove<TS, TP, TO, TG>(
        &mut self,
        s: &TS,
        p: &TP,
        o: &TO,
        g: Option<&TG>
    ) -> Result<bool, Self::MutationError>
    where
        TG: TTerm + ?Sized,
        TO: TTerm + ?Sized,
        TP: TTerm + ?Sized,
        TS: TTerm + ?Sized
; fn insert_all<QS>(
        &mut self,
        src: QS
    ) -> Result<usize, StreamError<<QS as QuadSource>::Error, Self::MutationError>>
    where
        QS: QuadSource
, { ... }
fn remove_all<QS>(
        &mut self,
        src: QS
    ) -> Result<usize, StreamError<<QS as QuadSource>::Error, Self::MutationError>>
    where
        QS: QuadSource
, { ... }
fn remove_matching<S, P, O, G>(
        &mut self,
        ms: &S,
        mp: &P,
        mo: &O,
        mg: &G
    ) -> Result<usize, Self::MutationError>
    where
        G: GraphNameMatcher + ?Sized,
        O: TermMatcher + ?Sized,
        P: TermMatcher + ?Sized,
        S: TermMatcher + ?Sized,
        <<Self::Quad as QuadStreamingMode>::UnsafeQuad as UnsafeQuad>::Term: Clone,
        Self::Error: Into<Self::MutationError>
, { ... }
fn retain_matching<S, P, O, G>(
        &mut self,
        ms: &S,
        mp: &P,
        mo: &O,
        mg: &G
    ) -> Result<(), Self::MutationError>
    where
        G: GraphNameMatcher + ?Sized,
        O: TermMatcher + ?Sized,
        P: TermMatcher + ?Sized,
        S: TermMatcher + ?Sized,
        <<Self::Quad as QuadStreamingMode>::UnsafeQuad as UnsafeQuad>::Term: Clone,
        Self::Error: Into<Self::MutationError>
, { ... } }

Generic trait for mutable RDF datasets.

NB: the semantics of this trait allows a dataset to contain duplicate quads; see also SetDataset.

Associated Types

type MutationError: 'static + Error

The error type that this dataset may raise during mutations.

Loading content...

Required methods

fn insert<TS, TP, TO, TG>(
    &mut self,
    s: &TS,
    p: &TP,
    o: &TO,
    g: Option<&TG>
) -> Result<bool, Self::MutationError> where
    TG: TTerm + ?Sized,
    TO: TTerm + ?Sized,
    TP: TTerm + ?Sized,
    TS: TTerm + ?Sized

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.

fn remove<TS, TP, TO, TG>(
    &mut self,
    s: &TS,
    p: &TP,
    o: &TO,
    g: Option<&TG>
) -> Result<bool, Self::MutationError> where
    TG: TTerm + ?Sized,
    TO: TTerm + ?Sized,
    TP: TTerm + ?Sized,
    TS: TTerm + ?Sized

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.

Loading content...

Provided methods

fn insert_all<QS>(
    &mut self,
    src: QS
) -> Result<usize, StreamError<<QS as QuadSource>::Error, Self::MutationError>> where
    QS: QuadSource

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.

fn remove_all<QS>(
    &mut self,
    src: QS
) -> Result<usize, StreamError<<QS as QuadSource>::Error, Self::MutationError>> where
    QS: QuadSource

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.

fn remove_matching<S, P, O, G>(
    &mut self,
    ms: &S,
    mp: &P,
    mo: &O,
    mg: &G
) -> Result<usize, Self::MutationError> where
    G: GraphNameMatcher + ?Sized,
    O: TermMatcher + ?Sized,
    P: TermMatcher + ?Sized,
    S: TermMatcher + ?Sized,
    <<Self::Quad as QuadStreamingMode>::UnsafeQuad as UnsafeQuad>::Term: Clone,
    Self::Error: Into<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.

fn retain_matching<S, P, O, G>(
    &mut self,
    ms: &S,
    mp: &P,
    mo: &O,
    mg: &G
) -> Result<(), Self::MutationError> where
    G: GraphNameMatcher + ?Sized,
    O: TermMatcher + ?Sized,
    P: TermMatcher + ?Sized,
    S: TermMatcher + ?Sized,
    <<Self::Quad as QuadStreamingMode>::UnsafeQuad as UnsafeQuad>::Term: Clone,
    Self::Error: Into<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.

Loading content...

Implementations on Foreign Types

impl<T, S> MutableDataset for HashSet<([T; 3], Option<T>), S> where
    S: BuildHasher,
    T: TTerm + CopyTerm + Eq + Hash
[src]

type MutationError = Infallible

impl<T> MutableDataset for Vec<([T; 3], Option<T>)> where
    T: TTerm + CopyTerm
[src]

type MutationError = Infallible

Loading content...

Implementors

impl<G, H> MutableDataset for GraphAsDataset<G, H> where
    G: MutableGraph,
    H: BorrowMut<G>, 
[src]

type MutationError = GraphAsDatasetError<<G as MutableGraph>::MutationError>

impl<I> MutableDataset for HashDataset<I> where
    I: TermIndexMap,
    I::Index: Hash,
    <I::Factory as TermFactory>::TermData: 'static, 
[src]

type MutationError = Infallible

impl<T> MutableDataset for GspoWrapper<T> where
    T: IndexedDataset + Dataset<Quad = ByTermRefs<Term<<T as IndexedDataset>::TermData>>>, 
[src]

type MutationError = Infallible

impl<T> MutableDataset for OgpsWrapper<T> where
    T: IndexedDataset + Dataset<Quad = ByTermRefs<Term<<T as IndexedDataset>::TermData>>>, 
[src]

type MutationError = Infallible

Loading content...