mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-20 16:29:31 +00:00
Splits the Rust codegen the way C++ is split: rename `rust.nim` -> `rust_cbor.nim` (CBOR) and add `rust_native.nim` (native). Dispatch on `targetLang=rust` now honours `-d:ffiMode` (native/cbor); the crates share file names so each mode writes its own dir (rust_bindings vs rust_native_bindings). `rust_native.nim` emits a `<lib>_native` crate — the Rust analogue of `cpp_native`: `#[repr(C)]` POD mirrors + `extern "C"` native entry points (ffi.rs); idiomatic structs with `to_c`/`from_c`, a holder owning the CStrings for the call (types.rs); and a `<Lib>Node` whose methods marshal typed args in / read typed struct returns out, blocking via std mpsc (api.rs). First cut: scalar/string/bool/float/nested-struct fields (create/version/echo); seq/Option params are SKIPPED, native events next. Verified end-to-end — the generated crate builds and the demo round-trips a typed EchoResponse. Tasks: genbindings_rust (CBOR), genbindings_rust_native. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>