mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-20 16:29:31 +00:00
Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Co-authored-by: Gabriel Cruz <8129788+gmelodie@users.noreply.github.com>
44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
# Rust Client Examples
|
|
|
|
## Purpose
|
|
|
|
This folder contains **example Rust applications** that demonstrate how to use the auto-generated `timer` crate (from `../rust_bindings`).
|
|
|
|
## What's Included
|
|
|
|
Two executable examples:
|
|
|
|
- **`rust_client`** — Synchronous example
|
|
- Shows basic synchronous calls to the Nim timer API
|
|
- Uses blocking wait with condition variables
|
|
- Source: `src/main.rs`
|
|
|
|
- **`tokio_client`** — Asynchronous example with Tokio runtime
|
|
- Demonstrates the Tokio async runtime integration
|
|
- Uses `spawn_blocking` to handle the blocking FFI callbacks on a separate thread pool
|
|
- Source: `src/tokio_main.rs`
|
|
|
|
## Building
|
|
|
|
```sh
|
|
cd examples/timer/rust_client
|
|
cargo build
|
|
```
|
|
|
|
## Running
|
|
|
|
```sh
|
|
# Sync example
|
|
cargo run --bin rust_client
|
|
|
|
# Tokio async example
|
|
cargo run --bin tokio_client
|
|
```
|
|
|
|
## Important Notes
|
|
|
|
- The `timer` crate is a **local dependency** (`path = "../rust_bindings"`)
|
|
- It is **auto-generated** — do not manually edit it
|
|
- These examples are **not** part of the generated output; they are hand-written to show usage patterns
|
|
- To regenerate the `timer` crate, run `nimble genbindings_rust` from the parent directory
|