Registry / Framework

framework · v0.1.2
Chapter Lock
Prevent a book export from racing a new chapter edit by sealing a numbered manuscript snapshot.
Use Chapter Lock
use vendor::chapter_lock::chapter_lock;
Run the example
nest demo chapter_lock@0.1.2
blyxc native-run chapter_lock-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::chapter_lock::chapter_lock;
fn main() {
let arguments = cli_args();
if args_len(arguments) > 0 {
if args_len(arguments) % 2 != 0 {
stderr_line("Expected event and value pairs");
process_exit(2);
}
let mut live = chapter_lock_start();
let mut i = 0;
while i < args_len(arguments) {
let input = args_at(arguments, i + 1);
if !text_is_number(input) {
stderr_line("Expected a whole numeric event value");
process_exit(2);
}
live = chapter_lock_step(live, args_at(arguments, i), text_number(input));
let command = chapter_lock_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = chapter_lock_start();
state = chapter_lock_step(state, "edit", 2.0);
println!(chapter_lock_command(state));
state = chapter_lock_step(state, "seal", 2.0);
println!(chapter_lock_command(state));
state = chapter_lock_step(state, "export", 2.0);
println!(chapter_lock_command(state));
state = chapter_lock_step(state, "finish", 1.0);
println!(chapter_lock_command(state));
state = chapter_lock_step(state, "finish", 2.0);
println!(chapter_lock_command(state));
}
Expected output
record_revision
freeze_manuscript
render_book
reject
index_edition
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | cff5ef95c9 | ce5a2c7d3942dc5b33de8e4d41127a2e5469e9aa3b2d2044f32079dd08fc9660 |
| 0.1.1 | Download ZIP · Browse files | ff87769639 | 27b53348a64f76130fbc9755414d915d6b27be0f8fb26eeb87e50b80c21a249f |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | d0a3ef0ac508e788a331da8f5afbb741489ecce8b80e3988668063aaf5748f75 |