use crate::entities::CeremonyIntervention;
use crate::value_objects::{
CeremonyContext, CeremonyId, CeremonyName, CeremonyTranscript, CeremonyVersion, RoleId,
Specialty, StateId, StepAttempt, StepHandlerConfig, StepHandlerKind, StepId,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CeremonyStepHandlerRequest {
instance_id: CeremonyId,
definition_name: CeremonyName,
definition_version: CeremonyVersion,
current_state: StateId,
step_id: StepId,
handler_kind: StepHandlerKind,
handler_config: StepHandlerConfig,
context: CeremonyContext,
attempt: StepAttempt,
transcript: CeremonyTranscript,
interventions: Vec<CeremonyIntervention>,
role_id: Option<RoleId>,
bound_specialty: Option<Specialty>,
}
impl CeremonyStepHandlerRequest {
#[must_use]
pub fn new(
instance_id: CeremonyId,
definition_name: CeremonyName,
definition_version: CeremonyVersion,
current_state: StateId,
step_id: StepId,
handler_kind: StepHandlerKind,
handler_config: StepHandlerConfig,
context: CeremonyContext,
attempt: StepAttempt,
) -> Self {
Self {
instance_id,
definition_name,
definition_version,
current_state,
step_id,
handler_kind,
handler_config,
context,
attempt,
transcript: CeremonyTranscript::empty(),
interventions: Vec::new(),
role_id: None,
bound_specialty: None,
}
}
#[must_use]
pub fn with_transcript(mut self, transcript: CeremonyTranscript) -> Self {
self.transcript = transcript;
self
}
#[must_use]
pub fn with_interventions(mut self, interventions: Vec<CeremonyIntervention>) -> Self {
self.interventions = interventions;
self
}
#[must_use]
pub fn with_bound_specialty(mut self, specialty: Option<Specialty>) -> Self {
self.bound_specialty = specialty;
self
}
#[must_use]
pub fn with_role(mut self, role_id: RoleId) -> Self {
self.role_id = Some(role_id);
self
}
#[must_use]
pub fn instance_id(&self) -> &CeremonyId {
&self.instance_id
}
#[must_use]
pub fn definition_name(&self) -> &CeremonyName {
&self.definition_name
}
#[must_use]
pub fn definition_version(&self) -> &CeremonyVersion {
&self.definition_version
}
#[must_use]
pub fn current_state(&self) -> &StateId {
&self.current_state
}
#[must_use]
pub fn step_id(&self) -> &StepId {
&self.step_id
}
#[must_use]
pub fn handler_kind(&self) -> &StepHandlerKind {
&self.handler_kind
}
#[must_use]
pub fn handler_config(&self) -> &StepHandlerConfig {
&self.handler_config
}
#[must_use]
pub fn context(&self) -> &CeremonyContext {
&self.context
}
#[must_use]
pub fn attempt(&self) -> StepAttempt {
self.attempt
}
#[must_use]
pub fn transcript(&self) -> &CeremonyTranscript {
&self.transcript
}
#[must_use]
pub fn interventions(&self) -> &[CeremonyIntervention] {
&self.interventions
}
#[must_use]
pub fn bound_specialty(&self) -> Option<&Specialty> {
self.bound_specialty.as_ref()
}
#[must_use]
pub fn role_id(&self) -> Option<&RoleId> {
self.role_id.as_ref()
}
}