Merge 7a5ab67831bd9da15acea086c354046dbd5f977d into 88c7c8b8b76598502e2d05475a65244c570b5d48

This commit is contained in:
Ivan FB 2026-05-31 19:39:02 +02:00 committed by GitHub
commit c83a6d9182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 21 additions and 13 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "my_timer"
name = "my_timer_cbor"
version = "0.1.0"
edition = "2021"

View File

@ -31,7 +31,8 @@ The `rust_client` example consumes this crate:
```toml
[dependencies]
my_timer = { path = "../rust_bindings" }
# CBOR (inter-process) crate carries the `_cbor` suffix; the native crate is the bare `my_timer`.
my_timer_cbor = { path = "../rust_bindings" }
```
## Do Not Edit

View File

@ -97,7 +97,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "my_timer"
name = "my_timer_cbor"
version = "0.1.0"
dependencies = [
"ciborium",
@ -134,7 +134,7 @@ dependencies = [
name = "rust_client"
version = "0.1.0"
dependencies = [
"my_timer",
"my_timer_cbor",
"serde_json",
"tokio",
]

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
my_timer = { path = "../rust_bindings" }
my_timer_cbor = { path = "../rust_bindings" }
serde_json = "1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

View File

@ -6,7 +6,7 @@
// To regenerate the `rust_bindings` crate:
// nimble genbindings_rust
use std::time::Duration;
use my_timer::{
use my_timer_cbor::{
EchoRequest, JobSpec, MyTimerCtx, RetryPolicy, ScheduleConfig, TimerConfig,
};

View File

@ -1,5 +1,5 @@
use std::time::Duration;
use my_timer::{
use my_timer_cbor::{
EchoRequest, JobSpec, MyTimerCtx, RetryPolicy, ScheduleConfig, TimerConfig,
};

View File

@ -1,4 +1,4 @@
[package]
name = "my_timer_native"
name = "my_timer"
version = "0.1.0"
edition = "2021"

View File

@ -1,4 +1,4 @@
use my_timer_native::*;
use my_timer::*;
fn main() {
let node = MyTimerNode::new(TimerConfig { name: "rust-native-gen".into() }).unwrap();
println!("version: {}", node.version().unwrap());

View File

@ -74,9 +74,13 @@ proc generateCargoToml*(libName: string): string =
# pulling its async-std/futures shims.
# `tokio` is needed only for `tokio::time::timeout` around the async
# `recv_async`. Feature-gating tokio (item 11) is a follow-up commit.
# CBOR (inter-process) crate carries the `_cbor` suffix, matching the
# `<name>_cbor` symbol naming and the C `<lib>_cbor.h` header; the native
# crate is the bare `<lib>`. The linked dylib is still `lib<lib>.dylib`
# (see generateBuildRs / the `#[link]` name) — only the crate name changes.
return
"""[package]
name = "$1"
name = "$1_cbor"
version = "0.1.0"
edition = "2021"

View File

@ -1,7 +1,8 @@
## Native (zero-serialization) Rust binding generator.
##
## Emits a `<lib>_native` crate that wraps the *native* C ABI (the `<name>`
## entry points + flat C-POD structs) — no CBOR. Each `{.ffi.}` type is a
## Emits a bare `<lib>` crate that wraps the *native* C ABI (the `<name>`
## entry points + flat C-POD structs) — no CBOR; the CBOR crate is `<lib>_cbor`.
## Each `{.ffi.}` type is a
## `#[repr(C)]` mirror (`ffi`) plus an idiomatic Rust struct with `to_c`/`from_c`
## (`types`), and `<Lib>Node` marshals typed args in / reads typed struct
## returns out (`api`). Counterpart of the CBOR generator in `rust_cbor.nim`, and
@ -452,8 +453,10 @@ proc generateRustNativeCrate*(
events: seq[FFIEventMeta] = @[],
) =
createDir(outputDir / "src")
# Native (same-process) crate is the bare `<lib>`, matching the `<name>`
# symbol naming and the C `<lib>.h` header; the CBOR crate is `<lib>_cbor`.
writeFile(outputDir / "Cargo.toml",
"[package]\nname = \"" & libName & "_native\"\nversion = \"0.1.0\"\nedition = \"2021\"\n")
"[package]\nname = \"" & libName & "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n")
writeFile(outputDir / "src" / "lib.rs",
"mod ffi;\nmod types;\nmod api;\npub use types::*;\npub use api::*;\n")
writeFile(outputDir / "src" / "ffi.rs", emitFfiRs(procs, types, libName, events))