Skip to main content

made_core/value_objects/ceremony/
child_join.rs

1use serde::{Deserialize, Serialize};
2
3use super::ChildQuorum;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6#[serde(tag = "kind", rename_all = "snake_case")]
7pub enum ChildJoin {
8    All,
9    Any,
10    Quorum { count: ChildQuorum },
11}
12
13impl ChildJoin {
14    #[must_use]
15    pub fn is_satisfied(self, completed: usize, total: usize) -> bool {
16        match self {
17            Self::All => total > 0 && completed == total,
18            Self::Any => completed > 0,
19            Self::Quorum { count } => completed >= usize::from(count.get()),
20        }
21    }
22}