Registry / Framework

framework · v0.1.2
Subtitle Clock
Accept nonoverlapping cues in timestamp order and mark the last closed cue for export.
Use Subtitle Clock
use vendor::subtitle_clock::subtitle_clock;
Run the example
nest demo subtitle_clock@0.1.2
blyxc native-run subtitle_clock-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::subtitle_clock::subtitle_clock;
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 = subtitle_clock_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 = subtitle_clock_step(live, args_at(arguments, i), text_number(input));
let command = subtitle_clock_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = subtitle_clock_start();
state = subtitle_clock_step(state, "begin", 10.0);
println!(subtitle_clock_command(state));
state = subtitle_clock_step(state, "end", 15.0);
println!(subtitle_clock_command(state));
state = subtitle_clock_step(state, "begin", 14.0);
println!(subtitle_clock_command(state));
state = subtitle_clock_step(state, "begin", 15.0);
println!(subtitle_clock_command(state));
state = subtitle_clock_step(state, "end", 19.0);
println!(subtitle_clock_command(state));
state = subtitle_clock_step(state, "export", 0.0);
println!(subtitle_clock_command(state));
}
Expected output
write_start
write_end
reject
write_start
write_end
seal_track
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | cfc0198f09 | 8693f425b9b198006399fc638ec3edd3035e98df1ca3e791c3aa6a3e2a5f5c97 |
| 0.1.1 | Download ZIP · Browse files | 99c4996026 | 1a9bce05c28ed404f23891f6f05a4d692f3824648994d633c344d671c1096d0c |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | 37455189b7565787f36cdaf0b5db7f9f6655ff18f9d4bfe7c912e67b32164c8b |