Skip to main content

made_core/entities/
publication_outcome.rs

1use crate::entities::PublishedCeremonyDefinition;
2use crate::value_objects::CeremonyDefinitionDigest;
3
4/// Result of idempotently publishing an immutable ceremony definition.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum PublicationOutcome {
7    Published(PublishedCeremonyDefinition),
8    AlreadyPublished(PublishedCeremonyDefinition),
9    VersionOccupied {
10        published: CeremonyDefinitionDigest,
11        offered: CeremonyDefinitionDigest,
12    },
13}
14
15impl PublicationOutcome {
16    #[must_use]
17    pub fn published(&self) -> Option<&PublishedCeremonyDefinition> {
18        match self {
19            Self::Published(published) | Self::AlreadyPublished(published) => Some(published),
20            Self::VersionOccupied { .. } => None,
21        }
22    }
23
24    #[must_use]
25    pub fn is_conflict(&self) -> bool {
26        matches!(self, Self::VersionOccupied { .. })
27    }
28
29    #[must_use]
30    pub fn is_new(&self) -> bool {
31        matches!(self, Self::Published(_))
32    }
33}