extern crate alloc;
use thiserror::Error;
use crate::metis::VersionVector;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Abandoned {
station: u32,
bound: VersionVector,
}
impl Abandoned {
pub(super) const fn new(station: u32, bound: VersionVector) -> Self {
Self { station, bound }
}
#[must_use]
pub const fn station(&self) -> u32 {
self.station
}
#[must_use]
pub const fn bound(&self) -> &VersionVector {
&self.bound
}
#[must_use]
pub fn counter(&self) -> u64 {
self.bound.get(self.station)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
pub enum AbandonRefusal {
#[error("cannot abandon station {station}: not on the roster")]
UnknownStation {
station: u32,
},
#[error("cannot abandon station {station}: it is the last surviving member")]
LastSurvivor {
station: u32,
},
#[error("station {station}'s attestation was agreed over another family")]
FamilyMismatch {
station: u32,
},
#[error(
"cannot abandon station {station}: it is the last server of station {stranded}'s attested bound"
)]
StrandsAttestation {
station: u32,
stranded: u32,
},
#[error("station {station} is already attested at {held}, not {offered}")]
Reattested {
station: u32,
held: u64,
offered: u64,
},
}