//! enstate: state next to the store (docs/design.md). //! //! * [`name`]: names of channels and slots, and addresses; //! * [`media`]: types, as media types; //! * [`schema`]: what a generation accepts; //! * [`content`]: the entries of one channel, and records in them; //! * [`submission`]: what gets handed to the host; //! * [`program`]: the protocol of validators, renderers, converters and steps; //! * [`view`]: rendering views, comparing them, installing them; //! * [`store`]: snapshots on disk, and the views in place; //! * [`plan`]: what a submission would do, and applying it; //! * [`pack`]: making a submission from a source list. pub mod content; pub mod media; pub mod name; pub mod pack; pub mod plan; pub mod program; pub mod schema; pub mod scratch; pub mod store; pub mod submission; pub mod view; /// A new identifier for a snapshot: a random UUID (version 4). pub fn new_id() -> anyhow::Result { use std::io::Read; let mut bytes = [0u8; 16]; std::fs::File::open("/dev/urandom")?.read_exact(&mut bytes)?; bytes[6] = (bytes[6] & 0x0f) | 0x40; bytes[8] = (bytes[8] & 0x3f) | 0x80; let hex: String = bytes.iter().map(|byte| format!("{byte:02x}")).collect(); Ok(format!( "{}-{}-{}-{}-{}", &hex[0..8], &hex[8..12], &hex[12..16], &hex[16..20], &hex[20..32] )) }