2026-05-11 23:28:17 +02:00
# Rust Bindings for nim-timer
## Purpose
2026-05-16 01:08:42 +02:00
This folder contains **auto-generated Rust bindings** (the `timer` crate) for the `timer` Nim library. It is generated from `../timer.nim` and provides:
2026-05-11 23:28:17 +02:00
2026-05-16 01:08:42 +02:00
- `src/lib.rs` : Main library exposing high-level Rust types and the `TimerCtx` API
2026-05-11 23:28:17 +02:00
- `src/api.rs` : High-level async/sync wrapper around the FFI
- `src/ffi.rs` : Raw `extern "C"` declarations for the Nim library
- `src/types.rs` : Serializable Rust types matching the Nim FFI types
2026-05-16 01:08:42 +02:00
- `build.rs` : Build script that compiles the Nim library to `libtimer.dylib` (or `.so` /`.dll` )
2026-05-11 23:28:17 +02:00
- `Cargo.toml` : Package manifest with serde and serde_json dependencies
## How It's Generated
Generate or regenerate these bindings by running from the parent directory:
```sh
2026-05-16 01:08:42 +02:00
cd examples/timer
2026-05-11 23:28:17 +02:00
nimble genbindings_rust
```
This command:
1. Invokes the Nim compiler with `-d:targetLang:rust` flag
2026-05-16 01:08:42 +02:00
2. Triggers `genBindings("examples/timer/rust_bindings", "../timer.nim")` in `timer.nim`
2026-05-11 23:28:17 +02:00
3. Creates/updates the generated binding files
## Using as a Dependency
The `rust_client` example consumes this crate:
```toml
[dependencies]
2026-05-16 01:08:42 +02:00
timer = { path = "../rust_bindings" }
2026-05-11 23:28:17 +02:00
```
## Do Not Edit
The generated files in this folder are overwritten each time `nimble genbindings_rust` runs. Any manual changes will be lost.