simple_triplestore/traits/
query.rs

1use crate::{
2    prelude::*,
3    traits::{IdType, Property},
4    Query,
5};
6
7#[derive(Debug)]
8pub enum QueryError<SourceError: std::fmt::Debug, ResultError: std::fmt::Debug> {
9    Left(SourceError),
10    Right(ResultError),
11}
12
13/// A trait for querying operations in a [TripleStore].
14///
15/// Supports arbitrary source, predicate, and object queries, as well as lookups for properties of nodes and edges.
16pub trait TripleStoreQuery<Id: IdType, NodeProps: Property, EdgeProps: Property>:
17    TripleStoreError
18{
19    /// The result type of a query.
20    type QueryResult: TripleStore<Id, NodeProps, EdgeProps>;
21    type QueryResultError: std::fmt::Debug;
22
23    /// Execute a query and return the result.
24    fn run(
25        &self,
26        query: Query<Id>,
27    ) -> Result<Self::QueryResult, QueryError<Self::Error, Self::QueryResultError>>;
28}