drasi_core/interface/
mod.rs1mod checkpoint_store;
16mod element_index;
17mod future_queue;
18mod index_backend;
19mod query_clock;
20mod result_index;
21mod session_control;
22mod source_middleware;
23
24use std::error::Error;
25use std::fmt::Display;
26
27pub use checkpoint_store::CheckpointStore;
28pub use checkpoint_store::SourceCheckpoint;
29use drasi_query_ast::api::QueryParseError;
30pub use element_index::ElementArchiveIndex;
31pub use element_index::ElementIndex;
32pub use element_index::ElementResult;
33pub use element_index::ElementStream;
34pub use future_queue::FutureElementRef;
35pub use future_queue::FutureQueue;
36pub use future_queue::FutureQueueConsumer;
37pub use future_queue::PushType;
38pub use index_backend::CreatedIndexes;
39pub use index_backend::IndexBackendPlugin;
40pub use index_backend::IndexSet;
41pub use query_clock::QueryClock;
42pub use result_index::AccumulatorIndex;
43pub use result_index::LazySortedSetStore;
44pub use result_index::ResultIndex;
45pub use result_index::ResultKey;
46pub use result_index::ResultOwner;
47pub use result_index::ResultSequence;
48pub use result_index::ResultSequenceCounter;
49pub use session_control::NoOpSessionControl;
50pub use session_control::SessionControl;
51pub use session_control::SessionGuard;
52pub use source_middleware::MiddlewareError;
53pub use source_middleware::MiddlewareSetupError;
54pub use source_middleware::SourceMiddleware;
55pub use source_middleware::SourceMiddlewareFactory;
56use thiserror::Error;
57
58use crate::evaluation::EvaluationError;
59
60#[derive(Debug)]
61pub enum IndexError {
62 IOError,
63 NotSupported,
64 CorruptedData,
65 ConnectionFailed(Box<dyn std::error::Error + Send + Sync>),
66 UnknownStore(String),
67 Other(Box<dyn std::error::Error + Send + Sync>),
68}
69
70impl PartialEq for IndexError {
71 fn eq(&self, other: &Self) -> bool {
72 match (self, other) {
73 (IndexError::IOError, IndexError::IOError) => true,
74 (IndexError::NotSupported, IndexError::NotSupported) => true,
75 (IndexError::CorruptedData, IndexError::CorruptedData) => true,
76 (IndexError::ConnectionFailed(a), IndexError::ConnectionFailed(b)) => {
77 a.to_string() == b.to_string()
78 }
79 (IndexError::UnknownStore(a), IndexError::UnknownStore(b)) => a == b,
80 (IndexError::Other(a), IndexError::Other(b)) => a.to_string() == b.to_string(),
81 _ => false,
82 }
83 }
84}
85impl Display for IndexError {
92 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
93 format!("{self:?}").fmt(f)
94 }
95}
96
97impl Error for IndexError {
98 fn source(&self) -> Option<&(dyn Error + 'static)> {
99 match self {
100 IndexError::Other(e) => Some(e.as_ref()),
101 _ => None,
102 }
103 }
104}
105
106impl IndexError {
107 pub fn other<E: std::error::Error + Send + Sync + 'static>(e: E) -> Self {
108 IndexError::Other(Box::new(e))
109 }
110
111 pub fn connection_failed<E: std::error::Error + Send + Sync + 'static>(e: E) -> Self {
112 IndexError::ConnectionFailed(Box::new(e))
113 }
114}
115
116#[derive(Error, Debug)]
117pub enum QueryBuilderError {
118 #[error("Middleware setup error: {0}")]
119 MiddlewareSetupError(MiddlewareSetupError),
120
121 #[error("Parser error: {0}")]
122 ParserError(QueryParseError),
123
124 #[error("Evaluation error: {0}")]
125 EvaluationError(EvaluationError),
126}
127
128impl From<MiddlewareSetupError> for QueryBuilderError {
129 fn from(e: MiddlewareSetupError) -> Self {
130 QueryBuilderError::MiddlewareSetupError(e)
131 }
132}
133
134impl From<QueryParseError> for QueryBuilderError {
135 fn from(e: QueryParseError) -> Self {
136 QueryBuilderError::ParserError(e)
137 }
138}
139
140impl From<EvaluationError> for QueryBuilderError {
141 fn from(e: EvaluationError) -> Self {
142 QueryBuilderError::EvaluationError(e)
143 }
144}