diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-29 14:25:25 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:58:46 +0200 |
| commit | 5777a555f60b780b7db430fa7bfa66a3bcb2623f (patch) | |
| tree | ef8878dc0cbacc4b164efed8a8bf685561302a46 /rust/README.md | |
| parent | 220ec757d42b54f498d031436e5b4b03931b165c (diff) | |
| download | opencut-5777a555f60b780b7db430fa7bfa66a3bcb2623f.tar.gz | |
feat: add shared Rust crates for cross-platform time utilities
Introduce `bridge` proc-macro crate with `#[export]` attribute that conditionally applies `wasm_bindgen` for WASM builds, and `time` crate porting all timecode/frame utilities from TypeScript to Rust.
Diffstat (limited to 'rust/README.md')
| -rw-r--r-- | rust/README.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/rust/README.md b/rust/README.md new file mode 100644 index 00000000..1048f66d --- /dev/null +++ b/rust/README.md @@ -0,0 +1,35 @@ +# rust/ + +Shared Rust crates that power OpenCut across platforms (web via WASM, desktop natively). + +## Adding a new crate + +1. Create it under `rust/crates/` +2. Add `bridge` as a dependency +3. Annotate public functions with `#[export]` + +## How `#[export]` works + +```rust +use bridge::export; + +#[export] +pub fn round_to_frame(time: f64, fps: f64) -> f64 { + (time * fps).round() / fps +} +``` + +Without the `wasm` feature, the macro is a no-op. With `--features wasm`, it expands to: + +```rust +#[wasm_bindgen(js_name = "roundToFrame")] +pub fn round_to_frame(time: f64, fps: f64) -> f64 { ... } +``` + +Desktop uses the crates directly as Cargo dependencies. + +## Testing + +```bash +cargo test -p <crate> +``` |
