simple_triplestore/traits/
extend.rs

1use crate::{prelude::*, traits::IdType, traits::Property};
2
3/// Wrapper for errors resulting from [TripleStoreExtend::extend()]
4#[derive(Debug)]
5pub enum ExtendError<LeftError: std::fmt::Debug, RightError: std::fmt::Debug> {
6    /// Error from the [TripleStore] being extended.
7    Left(LeftError),
8
9    /// Error from the [TripleStore] being consumed.
10    Right(RightError),
11}
12
13/// A trait for extending a [TripleStore] with elements from another [TripleStore].
14///
15/// Inserts all nodes and edges from `other` into this [TripleStore], replacing existing property data if present.
16pub trait TripleStoreExtend<Id: IdType, NodeProps: Property, EdgeProps: Property>:
17    TripleStoreError
18{
19    /// Extend this [TripleStore] with nodes and edges from `other`.
20    ///
21    /// Property data for existing nodes will be replaced with data from `other`.
22    fn extend<E: std::fmt::Debug>(
23        &mut self,
24        other: impl TripleStore<Id, NodeProps, EdgeProps, Error = E>,
25    ) -> Result<(), ExtendError<Self::Error, E>>;
26}