Registry / Framework

framework · v0.1.2
Annotation Budget
Reserve a bounded labeling budget, route affordable tasks and close the campaign when funds run out.
Use Annotation Budget
use vendor::annotation_budget::annotation_budget;
Run the example
nest demo annotation_budget@0.1.2
blyxc native-run annotation_budget-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::annotation_budget::annotation_budget;
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 = annotation_budget_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 = annotation_budget_step(live, args_at(arguments, i), text_number(input));
let command = annotation_budget_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = annotation_budget_start();
state = annotation_budget_step(state, "fund", 10.0);
println!(annotation_budget_command(state));
state = annotation_budget_step(state, "quote", 12.0);
println!(annotation_budget_command(state));
state = annotation_budget_step(state, "quote", 4.0);
println!(annotation_budget_command(state));
state = annotation_budget_step(state, "quote", 6.0);
println!(annotation_budget_command(state));
state = annotation_budget_step(state, "extend", 3.0);
println!(annotation_budget_command(state));
state = annotation_budget_step(state, "close", 0.0);
println!(annotation_budget_command(state));
}
Expected output
set_budget
defer_task
assign_task
assign_last
set_budget
return_unused
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | fa9c9d33ad | e7e604035ef62160e020a23b9d5ad8b742b464201d87fee9aa4ca01213e907b9 |
| 0.1.1 | Download ZIP · Browse files | 01701c5786 | 08b9799808804d2cdc25b07937d2875b095f2cce7a499587d9d12794d06c4f6e |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | dcd51ad6118843ec607727bb152b34efce7881fd60e9e0c207deed850265ca21 |