Numbers are derived from the repository at engine version 0.3.0 (edition 2021): the engine library crate counts every .rs file under src/ — the crate's [lib] path = "src/lib.rs" is the compiled source set. The C ABI lives in the sibling capi/ crate. A non-MIT UNLICENSED license; publish = false.
Crate layout
| crate | name | crate-type | role |
|---|---|---|---|
| engine | ztranslator-engine (lib ztranslator) | rlib (default) | the engine: model, sources, rules VM, BOME import/export, action executors |
| capi/ | ztranslator-capi | rlib · staticlib · cdylib | C ABI over the engine for non-Tauri hosts (zt_invoke + event callback) |
| tauri/ | tauri-plugin-ztranslator | (plugin crate) | Tauri-plugin bridge for webview hosts (Audio-Haxor, traderview) |
The README's rlib + staticlib + cdylib badge describes the ztranslator-capi crate; the engine library crate itself declares no crate-type and so builds as the default rlib.
Module map (engine)
| module | responsibility |
|---|---|
| model | Project > Preset > Translator data model; Incoming (28 trigger variants) and Outgoing (41 action variants); MIDI / keystroke / mouse / timer / route specs; JSON load_json / save_json |
| rules | signed-32-bit integer VM: Operand, BinOp (add sub mul div mod and or xor shl shr), CmpOp, Rule (Assign · Expr · Goto · Label · Log · SkipNext · ExitExecute · ExitIgnore · If · Comment); locals + globals; parse_program / program_to_source |
| matcher | matches an incoming event against a translator's Incoming spec, binding captured values for the rules VM |
| engine | Engine + worker thread: open inputs/outputs, virtual ports, router edges, start/stop, panic, test-fire; opens the non-MIDI trigger sources; emits EngineEvent to a sink |
| sources | non-MIDI trigger sources: OSC, Art-Net / sACN DMX, file watcher, serial, gamepad, HID, HTTP / WebSocket / MQTT / TCP, cron schedule, system events, audio level, Ableton Link |
| midi | MidiMessage parsing / encoding |
| actions | outgoing action executors; actions/macos.rs holds the OS-control paths (keystroke, mouse, AppleScript) that no-op off macOS |
| bmtp | BOME .bmtp import / import_str / export; option + payload parsing (parse_incoming / parse_outgoing) |
| transform · expr · logic · macros | the pure match → transform → emit value transforms; the AutoHotkey-v2 numeric-expression subset evaluator; the conditional rule-tree evaluator with a variable store (if/else/while); multi-step macro expansion and leader-key sequences |
| keystate · keyrec · hid · pointer · gesture · streamdeck | tap-hold resolution, chord/combo detection and layer state; key-sequence recording and normalization; the USB-HID keyboard usage table (page 0x07); pointer clamping, relative-move accumulation and scroll; trackpad gesture triggers; the Stream Deck paged key grid |
| theory · arp · groove · modulation · matrix · timing | note-name ↔ number, chords and scales; arpeggiator and step sequencer; swing/groove quantization; LFO and ADSR value-over-time sources; the continuous-controller → discrete-action band matrix; MIDI clock / SPP math with debounce and auto-repeat |
| midi2 · midici · smf · osc | MIDI 2.0 Universal MIDI Packets and MPE; MIDI-CI capability inquiry and property exchange; Standard MIDI File primitives (VLQ, MThd/MTrk); OSC 1.0 wire encode/decode |
| import · diff · lint · reach · feedback · verify | importers for rival remappers’ rule sets, and the static-analysis originals over an authored project: exhaustive behavioural diff, config lint, trigger reachability and overlap, feedback/cascade cycle detection, and interval-abstract-interpretation rule verification |
| serial · keycodes · error · timers | serial-port plumbing; key-code tables; Error / Result; engine timers |
C-ABI surface
The ztranslator-capi crate exports 4 extern "C" symbols; zt_invoke dispatches 127 distinct ztr_* commands.
void zt_set_event_callback(void (*cb)(const char* event_json)); char* zt_init(void); char* zt_invoke(const char* cmd, const char* args_json); void zt_string_free(char* s);
Dispatch commands cover lifecycle (ztr_engine_start · ztr_engine_stop · ztr_panic), ports / routes (ztr_list_ports · ztr_open_input · ztr_open_output · ztr_create_virtual_input · ztr_set_route), projects & rules (ztr_set_project · ztr_get_project · ztr_parse_rules · ztr_format_rules · ztr_save_json · ztr_load_json), and the non-MIDI sources (ztr_open_osc_input · ztr_open_artnet_input · ztr_watch_path · ztr_open_serial_input · ztr_open_gamepad_input · ztr_open_http_input · ztr_open_ws_input · ztr_open_mqtt_input · ztr_open_hid_input · ztr_open_schedule · ztr_open_sysevent · ztr_open_sacn_input · ztr_open_tcp_input · ztr_open_audio_input · ztr_open_link_input · ztr_open_rtpmidi_input · ztr_open_cv_output · ztr_inject_sysevent · ztr_close_source).
Dependency footprint
19 direct dependencies (plus 4 gated to macOS), all pure-Rust / foundational. Trigger and transport crates: midir (MIDI), rosc (OSC), serialport, notify (file watch), gilrs (gamepad), hidapi (USB-HID), tiny_http / ureq / tungstenite / rumqttc (HTTP / WebSocket / MQTT), cron + chrono (schedules), if-addrs + socket2 (network / sACN), rusty_link (Ableton Link). Art-Net DMX is decoded inline from a plain UDP packet — no crate. Data layer: serde + serde_json, thiserror, crossbeam-channel. The OS-control executors and audio input are gated to cfg(target_os = "macos") (core-graphics, core-foundation, foreign-types, cpal) so the cross-platform build stays dependency-clean.
Verification
235 test functions: 43 integration tests across tests/bmtp_import.rs, tests/diff_projects.rs, tests/engine_pipeline.rs, tests/rules_vm.rs and tests/verify_program.rs, plus 192 inline #[test] functions in the engine source. The BOME importer is driven against real .bmtp fixtures (Note Transpose, Controller Value Scaling, Simple Arpeggiator, Conditional MIDI mapping, one-shot timer, and an Ableton project). The rules suite exercises the integer VM's arithmetic / bitwise ops, conditionals, jumps, and execute / ignore outcomes; the pipeline suite drives the engine end to end. The deterministic core builds and runs in a headless Linux CI; macOS-only OS-control paths no-op off macOS.