Docs

frontier

Source: crates/lvcs-doc/src/frontier.rs.

/// A frontier id (design §2): the `HASH` of the canonical CBOR map from
/// document address to its sorted heads. Written in `ID_ENCODING`; its one
/// implementation is [`Frontier::id`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct FrontierId(#[serde(with = "crate::cbor::fixed")] pub [u8; 32]);

/// A frontier (design §2): each document's heads, by address. Its canonical
/// CBOR encoding is the map itself, each head a 32-byte byte string, so a
/// frontier with sorted head lists encodes as exactly what its id hashes.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct Frontier {
    #[serde(with = "crate::cbor::head_map")]
    pub docs: BTreeMap<String, Vec<ChangeHash>>,
}

/// Whether one set of a document's heads descends from another (decision
/// 120): `Yes` when every change in `from` is in the history of `heads`
/// (equal sets included), `No` when one is not, and `Unknown` when the
/// document lacks a change of either set, so a peer short of history
/// decides nothing until sync supplies it.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Descent {
    Yes,
    No,
    Unknown,
}