extern crate alloc;
use alloc::collections::BTreeMap;
use crate::kairos::{Clock, TickCounter};
use crate::metis::{Composer, Dot, DotFun, DotMap, Rhapsody};
pub type BlockDot = Dot;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Field {
Kind,
Title,
}
pub type FieldStore = DotMap<BlockDot, DotMap<Field, DotFun<&'static str>>>;
pub type ParaStore = DotMap<BlockDot, Rhapsody>;
pub type TableStore = DotMap<BlockDot, DotMap<u32, DotFun<&'static str>>>;
pub struct Page {
pub(super) station: u32,
pub(super) order: Composer<Rhapsody>,
pub(super) fields: Composer<FieldStore>,
pub(super) para: Composer<ParaStore>,
pub(super) table: Composer<TableStore>,
pub(super) chars: BTreeMap<Dot, char>,
pub(super) clock: Clock<TickCounter>,
}
impl Page {
#[must_use]
pub fn new(station: u32) -> Self {
let clock = Clock::with_default_config(TickCounter::new(), station).unwrap();
Self {
station,
order: Composer::new(station),
fields: Composer::new(station),
para: Composer::new(station),
table: Composer::new(station),
chars: BTreeMap::new(),
clock,
}
}
#[must_use]
pub const fn station(&self) -> u32 {
self.station
}
#[must_use]
pub const fn chars(&self) -> &BTreeMap<Dot, char> {
&self.chars
}
}