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#[allow(clippy::derive_partial_eq_without_eq)]
19#[derive(Debug, Clone, PartialEq, Default)]
20pub enum ExpressionHookResult {
21 #[default]
23 Continue,
24 Skip,
26 SkipWithType(TUnion),
28}
29
30impl ExpressionHookResult {
31 #[inline]
33 #[must_use]
34 pub fn should_skip(&self) -> bool {
35 !matches!(self, ExpressionHookResult::Continue)
36 }
37
38 #[inline]
40 #[must_use]
41 pub fn take_type(self) -> Option<TUnion> {
42 match self {
43 ExpressionHookResult::SkipWithType(ty) => Some(ty),
44 _ => None,
45 }
46 }
47}