use crate::value::Value;
pub mod prov;
use prov::{Origin, Prov};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Position(pub u64);
pub(crate) trait Attachment: Clone {
type View: Copy + Default;
type Crossing;
type Witness: ?Sized;
type Key: std::hash::Hash + Eq + Clone;
fn view(&self) -> Self::View;
fn key(&self) -> Self::Key;
fn bare(&self) -> Self;
fn standing(view: &Self::View) -> bool;
}
impl Attachment for () {
type View = ();
type Crossing = ();
type Witness = ();
type Key = ();
fn view(&self) -> Self::View {}
fn key(&self) -> Self::Key {}
fn bare(&self) -> Self {}
fn standing(_: &()) -> bool {
false
}
}
#[derive(Clone)]
pub(crate) struct Reg {
pub(crate) name: Option<String>,
pub(crate) value: Value,
pub(crate) prov: Prov,
#[allow(dead_code)]
pub(crate) site: Origin,
}
#[derive(Clone)]
pub(crate) struct Thread<X: Attachment> {
pub(crate) register: Vec<Reg>,
pub(crate) topic: Option<Value>,
pub(crate) prov: Prov,
pub(crate) members: Vec<Thread<X>>,
pub(crate) captures: Vec<String>,
pub(crate) named: Vec<(String, String)>,
pub(crate) ext: X,
}
impl<X: Attachment> Thread<X> {
pub(crate) fn bare(ext: X, topic: Option<Value>) -> Thread<X> {
Thread {
register: Vec::new(),
topic,
prov: Prov::default(),
members: Vec::new(),
captures: Vec::new(),
named: Vec::new(),
ext,
}
}
}