minerva 0.2.0

Causal ordering for distributed systems
use thiserror::Error;

/// A zero station ID supplied to a clock constructor.
#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
#[error("invalid station_id: station_id must be non-zero")]
pub struct InvalidStationId;

/// Error returned by [`Clock::try_observe`](super::Clock::try_observe) when a remote stamp's
/// forward skew exceeds the caller-supplied bound.
///
/// The clock is left *unchanged*: a rejected remote has no effect, so the caller
/// may drop, quarantine, or eject the peer without a partial state change to undo.
/// Both magnitudes are in the time source's own units (the `u64` domain of
/// [`Kairos::physical`](crate::kairos::Kairos::physical)), so a nanosecond source reads them as
/// nanoseconds.
#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
#[error("remote forward skew {observed_forward_skew} exceeds bound {max_forward_skew}")]
pub struct SkewExceeded {
    /// How far the remote `physical` ran ahead of the local reading.
    pub observed_forward_skew: u64,
    /// The bound the caller passed to [`Clock::try_observe`](super::Clock::try_observe).
    pub max_forward_skew: u64,
}