mant_query/
scope_query.rs1mod input;
3mod search;
4pub use input::{QueryScopeView, ScopeInputError};
5pub use search::search_scope;
6
7use std::{error::Error, fmt};
8
9#[derive(Debug, Clone, PartialEq, Eq)]
11pub enum ScopeExecutionError {
12 Explanation(crate::ExplanationError),
14 Search(crate::SearchError),
16 NoReadableDocuments {
18 reasons: Vec<String>,
20 },
21}
22
23impl fmt::Display for ScopeExecutionError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 match self {
26 Self::Explanation(error) => error.fmt(f),
27 Self::Search(error) => error.fmt(f),
28 Self::NoReadableDocuments { reasons } => {
29 f.write_str("none of the supplied documents contains readable content")?;
30 if !reasons.is_empty() {
31 write!(f, ": {}", reasons.join("; "))?;
32 }
33 Ok(())
34 }
35 }
36 }
37}
38
39impl Error for ScopeExecutionError {
40 fn source(&self) -> Option<&(dyn Error + 'static)> {
41 match self {
42 Self::Explanation(error) => Some(error),
43 Self::Search(error) => Some(error),
44 Self::NoReadableDocuments { .. } => None,
45 }
46 }
47}
48
49pub fn explain_scope(
55 input: QueryScopeView<'_>,
56 query: &mant_protocol::ExplanationQuery,
57) -> Result<mant_protocol::ScopeExplanation, ScopeExecutionError> {
58 crate::explanation::explain_scope(input, query)
59}