extern crate alloc;
use crate::kairos::{Clock, TickCounter};
use crate::metis::{Anchor, Dot, DotSet, Dotted, Locus, Metatheses, RefoundMap, Rhapsody};
mod examples;
mod properties;
type Seq = Dotted<Rhapsody>;
fn d(station: u32, counter: u64) -> Dot {
Dot::from_parts(station, counter).expect("a test literal names a real dot")
}
fn clock(station: u32) -> Clock<TickCounter> {
Clock::with_default_config(TickCounter::new(), station).unwrap()
}
fn woven(dot: Dot, locus: Locus) -> Seq {
let mut rhapsody = Rhapsody::new();
assert!(rhapsody.weave(dot, locus));
Dotted::from_store(rhapsody)
}
fn insert(replica: &mut Seq, clk: &Clock<TickCounter>, station: u32, anchor: Anchor) -> Dot {
let dot = replica.next_dot(station);
let locus = Locus {
anchor,
rank: clk.now(0u16),
};
*replica = replica.merge(&woven(dot, locus));
dot
}
fn delete(replica: &mut Seq, dot: Dot) {
let mut ctx = DotSet::new();
assert!(ctx.insert(dot));
*replica = replica.merge(&Dotted::from_context(ctx));
}
fn fixture_map() -> RefoundMap {
let mut replica: Seq = Dotted::new();
let one = clock(1);
let two = clock(2);
let a = insert(&mut replica, &one, 1, Anchor::Origin);
let b = insert(&mut replica, &one, 1, Anchor::After(a.into()));
let _c = insert(&mut replica, &one, 1, Anchor::After(b.into()));
let _d = insert(&mut replica, &two, 2, Anchor::Before(a.into()));
delete(&mut replica, b);
let refounded = replica
.store()
.refound(&Metatheses::new())
.expect("a sealed stratum folds");
let (_, map) = refounded.into_parts();
map
}