made_core/entities/ceremony_instance/
participant_bindings.rs1use crate::entities::ceremony_commands::BindParticipant;
2use crate::entities::CeremonyCommand;
3
4use super::{
5 BTreeMap, CeremonyDefinition, CeremonyInstance, CeremonyParticipantBinding, DomainError,
6 OffsetDateTime, RoleId, Specialty,
7};
8
9impl CeremonyInstance {
10 pub fn bind_participant(
19 &mut self,
20 definition: &CeremonyDefinition,
21 role_id: RoleId,
22 specialty: Specialty,
23 now: OffsetDateTime,
24 ) -> Result<(), DomainError> {
25 let command = CeremonyCommand::BindParticipant(BindParticipant {
26 role_id,
27 specialty,
28 now,
29 });
30 let events = self.decide(&command, definition)?;
31 self.apply_all(&events);
32 Ok(())
33 }
34
35 #[must_use]
36 pub fn participant_bindings(&self) -> &BTreeMap<RoleId, CeremonyParticipantBinding> {
37 &self.participant_bindings
38 }
39
40 #[must_use]
43 pub fn bound_specialty(&self, role_id: &RoleId) -> Option<&Specialty> {
44 self.participant_bindings
45 .get(role_id)
46 .map(CeremonyParticipantBinding::specialty)
47 }
48}