Skip to main content

actrpc_core/interception/
response.rs

1use crate::action::RequestedActionRecord;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5#[serde(rename_all = "snake_case")]
6pub enum InterceptorContinuation {
7    /// Rerun the same interceptor after orchestrator action execution.
8    Reinvoke,
9    /// Proceed to the next interceptor.
10    Stop,
11}
12
13#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
14pub struct InterceptionResponse {
15    #[serde(default, skip_serializing_if = "Vec::is_empty")]
16    pub actions: Vec<RequestedActionRecord>,
17    pub continuation: InterceptorContinuation,
18}
19
20impl InterceptionResponse {
21    pub fn has_actions(&self) -> bool {
22        !self.actions.is_empty()
23    }
24
25    pub fn should_reinvoke(&self) -> bool {
26        matches!(self.continuation, InterceptorContinuation::Reinvoke)
27    }
28
29    pub fn should_stop(&self) -> bool {
30        matches!(self.continuation, InterceptorContinuation::Stop)
31    }
32}