Skip to main content

made_core/ports/
ceremony_execution_request.rs

1use crate::ports::CeremonyStepHandlerRequest;
2use crate::value_objects::ExecutionIntent;
3
4/// Boundary request carrying both durable identity and handler-shaped work.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct CeremonyExecutionRequest {
7    intent: ExecutionIntent,
8    handler_request: CeremonyStepHandlerRequest,
9}
10
11impl CeremonyExecutionRequest {
12    pub fn new(
13        intent: ExecutionIntent,
14        handler_request: CeremonyStepHandlerRequest,
15    ) -> Result<Self, crate::DomainError> {
16        if intent.operation().request() != &handler_request.semantic_request_bytes()? {
17            return Err(crate::DomainError::InvariantViolated {
18                reason: "handler request does not match the sealed execution request",
19            });
20        }
21        Ok(Self {
22            intent,
23            handler_request,
24        })
25    }
26
27    #[must_use]
28    pub const fn intent(&self) -> &ExecutionIntent {
29        &self.intent
30    }
31
32    #[must_use]
33    pub const fn handler_request(&self) -> &CeremonyStepHandlerRequest {
34        &self.handler_request
35    }
36}