use crate::value_objects::IntegratorBinding;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BindOutcome {
Bound(IntegratorBinding),
AlreadyBound(IntegratorBinding),
Replaced {
previous: Box<IntegratorBinding>,
current: Box<IntegratorBinding>,
},
AlreadyExists { existing: Box<IntegratorBinding> },
}
impl BindOutcome {
#[must_use]
pub const fn current(&self) -> Option<&IntegratorBinding> {
match self {
Self::Bound(binding) | Self::AlreadyBound(binding) => Some(binding),
Self::Replaced { current, .. } => Some(current),
Self::AlreadyExists { .. } => None,
}
}
#[must_use]
pub const fn is_bound(&self) -> bool {
!matches!(self, Self::AlreadyExists { .. })
}
}