minerva 0.2.0

Causal ordering for distributed systems
extern crate alloc;

use alloc::vec::Vec;

use crate::kairos::Kairos;
use crate::metis::{Anchor, Locus, Rhapsody};

use super::d;
use crate::metis::dot::RawDot;

mod canonical;
mod framing;
mod layout;
mod suffix;

/// A rank with a known 17-byte frame: `Kairos::new(physical, 0, 1, 0)`, whose
/// `to_bytes` is `0x01` then the 16-byte big-endian payload. The payload here is
/// `physical << 64 | station(1)`, i.e. the physical value in the top 8 bytes and
/// `1` in the bottom byte.
fn rank(physical: u64) -> Kairos {
    Kairos::new(physical, 0u16, 1, 0u16)
}

fn canonical_frame() -> Vec<u8> {
    let mut rhapsody = Rhapsody::new();
    assert!(rhapsody.weave(
        d(1, 1),
        Locus {
            anchor: Anchor::Origin,
            rank: rank(7)
        }
    ));
    assert!(rhapsody.weave(
        d(1, 2),
        Locus {
            anchor: Anchor::After(RawDot {
                station: 1,
                counter: 1
            }),
            rank: rank(9),
        }
    ));
    rhapsody.to_bytes()
}