diff options
| author | tslil <tslil@posteo.de> | 2026-03-21 08:49:35 +0000 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-03-21 17:26:50 +0000 |
| commit | c22cc3b348bdcb446fb0e44070da36fdf6b05800 (patch) | |
| tree | 81371ff735529e7b2a5b1727be9c8b06123609e6 /rprt-engine/src/evaluate.rs | |
| parent | 5a5da7bc299bee12072e421d1936554690e34dd6 (diff) | |
big rework to support evaluation of selection functions, WiP
Diffstat (limited to 'rprt-engine/src/evaluate.rs')
| -rw-r--r-- | rprt-engine/src/evaluate.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/rprt-engine/src/evaluate.rs b/rprt-engine/src/evaluate.rs new file mode 100644 index 0000000..f6fee8a --- /dev/null +++ b/rprt-engine/src/evaluate.rs @@ -0,0 +1,43 @@ +use crate::{ + expression::Composite, + selection::{Selection, VectoriseError}, + selection_functions::{evaluate_selection_function, SFError}, + state::{EditorState, StateResult}, +}; + +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum EvaluationError { + #[error("{0}")] + SelectionFunctionError(VectoriseError<SFError>), + #[error("Not yet implemented {0}")] + UnimplementedError(&'static str), +} + +pub fn evaluate( + es: &EditorState, + comp: Composite, + left: Option<Selection>, + right: Option<Selection>, +) -> Result<StateResult, EvaluationError> { + match comp { + Composite::SelectionFunction { + func, + search_mod, + result_transform, + } => { + let sel = + evaluate_selection_function(es, func, search_mod, result_transform, left, right) + .map_err(EvaluationError::SelectionFunctionError)?; + Ok((sel, Vec::new())) + } + Composite::TextFunction { func, swapped } => { + Err(EvaluationError::UnimplementedError("text function")) + } + Composite::Hook { kind, left, right } => Err(EvaluationError::UnimplementedError("hook")), + Composite::Train2 { f, g } => Err(EvaluationError::UnimplementedError("train2")), + Composite::Train3 { f, g, h } => Err(EvaluationError::UnimplementedError("train3")), + Composite::Group { operations } => Err(EvaluationError::UnimplementedError("group")), + } +} |
