mago_analyzer/plugin/hook/
action.rs1use mago_codex::ttype::union::TUnion;
4
5use crate::plugin::error::PluginError;
6
7pub type HookResult<T> = Result<T, PluginError>;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11pub enum HookAction {
12 #[default]
13 Continue,
14 Skip,
15}
16
17#[derive(Debug, Clone, PartialEq, Default)]
19pub enum ExpressionHookResult {
20 #[default]
22 Continue,
23 Skip,
25 SkipWithType(TUnion),
27}
28
29impl ExpressionHookResult {
30 #[inline]
32 #[must_use]
33 pub fn should_skip(&self) -> bool {
34 !matches!(self, ExpressionHookResult::Continue)
35 }
36
37 #[inline]
39 #[must_use]
40 pub fn take_type(self) -> Option<TUnion> {
41 match self {
42 ExpressionHookResult::SkipWithType(ty) => Some(ty),
43 _ => None,
44 }
45 }
46}