minerva 0.2.0

Causal ordering for distributed systems
use super::Cut;
use crate::metis::{DotSet, VersionVector};

impl Cut {
    /// Borrows the witnessed vector.
    ///
    /// The read the adoption bridge rides: `tracker.report(peer,
    /// cut.as_vector())` feeds [`Stability`](crate::metis::Stability) with no
    /// signature change, because the honest report was always a
    /// `&VersionVector`. Borrowing keeps the witness; see
    /// [`into_vector`](Self::into_vector) for the one-way surrender.
    #[must_use]
    pub const fn as_vector(&self) -> &VersionVector {
        &self.0
    }

    /// Surrenders the witnessed vector, consuming the `Cut`.
    ///
    /// One-way: a bare [`VersionVector`] cannot come back to being a `Cut`
    /// (there is no vector-taking constructor), so surrendering drops the
    /// witness deliberately. The read for a caller that needs the owned vector
    /// and no longer needs the proof.
    #[must_use]
    pub fn into_vector(self) -> VersionVector {
        self.0
    }

    /// The have-set embedding of the cut: every dot at or below it held, nothing
    /// above, no holes ([`DotSet::from_witnessed`]).
    ///
    /// For difference and owed arithmetic over cuts. Round-trips: the embedding's
    /// [`floor`](DotSet::floor) restores the witnessed vector.
    #[must_use]
    pub fn to_have_set(&self) -> DotSet {
        DotSet::from_cut(&self.0)
    }
}