diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..af7de7e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,42 @@ +//! 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<String> { + 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] + )) +} |
