diff options
| author | tv <tv@krebsco.de> | 2026-11-29 14:21:34 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 14:59:15 +0000 |
| commit | eaac60ba88728bb582778c726e5798156dddfc45 (patch) | |
| tree | 557f4709762f95a7a440d1fa919dcce3bbf83cb4 /src/lib.rs | |
| parent | 70367d17613ebe501fb2d3e9fa72b16c2eb9c2bd (diff) | |
enstate: the receptor and the provider, a first version
One program on a library: --plan and --apply of submissions (complete and
partial, items required and optional, groups, removal, the chain as
order), validators of types and across slots, views put in place by
replacing a link, their reactions by systemctl; --status, --materialize;
and --pack, a submission from a source list in JSON or TOML, by the
config crate's sources. Programs by the protocol of design.md 5.2;
tests with shell scripts as validators and renderers.
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] + )) +} |
