Registry / Framework

framework · v0.1.2
Dock Appointments
Keep a loading bay available until its booked arrival time and account for late arrivals.
Use Dock Appointments
use vendor::dock_appointments::dock_appointments;
Run the example
nest demo dock_appointments@0.1.2
blyxc native-run dock_appointments-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::dock_appointments::dock_appointments;
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 = dock_appointments_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 = dock_appointments_step(live, args_at(arguments, i), text_number(input));
let command = dock_appointments_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = dock_appointments_start();
state = dock_appointments_step(state, "book", 20.0);
println!(dock_appointments_command(state));
state = dock_appointments_step(state, "arrive", 27.0);
println!(dock_appointments_command(state));
state = dock_appointments_step(state, "depart", 0.0);
println!(dock_appointments_command(state));
}
Expected output
reserve_dock
record_lateness
free_dock
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 4de56f4b67 | 062c08fe416ea9efc0a7e61d798ce85275fe5d4ef42bd7d44f41c06db7763857 |
| 0.1.1 | Download ZIP · Browse files | e2594e8ecf | cca44d9a4d107bd660d914b03ab2a1ef8517f1b2706cdc323d7db0b2d47a2df5 |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | 9fda6ac6c17f6365e1202cd0009523e6bd5c0259d9ea1e43fa2da9dd29171da6 |