simple_triplestore/traits/
set.rs

1use crate::{prelude::*, traits::IdType, traits::Property};
2
3#[derive(Debug)]
4pub enum SetOpsError<
5    LeftError: std::fmt::Debug,
6    RightError: std::fmt::Debug,
7    ResultError: std::fmt::Debug,
8> {
9    Left(LeftError),
10    Right(RightError),
11    Result(ResultError),
12}
13
14/// A trait for basic set operations in a memory-based [TripleStore].
15///
16/// Provides functionality for union, intersection, and difference operations on sets of triples.
17pub trait TripleStoreSetOps<Id: IdType, NodeProps: Property, EdgeProps: Property>:
18    TripleStoreError
19{
20    /// The result type for set operations.
21    type SetOpsResult: TripleStore<Id, NodeProps, EdgeProps>;
22    type SetOpsResultError: std::fmt::Debug;
23
24    /// Set union of properties and triples with another [TripleStore].
25    fn union<E: std::fmt::Debug>(
26        self,
27        other: impl TripleStoreIntoIter<Id, NodeProps, EdgeProps, Error = E>,
28    ) -> Result<Self::SetOpsResult, SetOpsError<Self::Error, E, Self::SetOpsResultError>>;
29
30    /// Set intersection of properties and triples with another [TripleStore].
31    fn intersection<E: std::fmt::Debug>(
32        self,
33        other: impl TripleStoreIntoIter<Id, NodeProps, EdgeProps, Error = E>,
34    ) -> Result<Self::SetOpsResult, SetOpsError<Self::Error, E, Self::SetOpsResultError>>;
35
36    /// Set difference of properties triples with another [TripleStore].
37    fn difference<E: std::fmt::Debug>(
38        self,
39        other: impl TripleStoreIntoIter<Id, NodeProps, EdgeProps, Error = E>,
40    ) -> Result<Self::SetOpsResult, SetOpsError<Self::Error, E, Self::SetOpsResultError>>;
41}