rns-embedded-ffi
rns-embedded-ffi exposes two C-facing surfaces:
- legacy compatibility entrypoints for manual tick plus raw wire ingress/egress
- the
v1node-centric API for lifecycle, status, send/broadcast, and event subscriptions
The public header is include/rns_embedded_ffi.h.
Surface labels:
- stable core: v1 lifecycle, status, send/broadcast, capability probe, subscriptions, structured errors
- compatibility surface: legacy manual tick + raw wire ingress/egress
- extension surface:
RnsEmbeddedV1EventKind::Extensionwith numeric IDs validated against docs/fixtures/embedded/public-node-api-v1/extension-ids.json
v1 API Summary
Use the v1 API when you want a stable node handle instead of wiring transport primitives manually:
rns_embedded_v1_node_newrns_embedded_v1_get_capabilitiesrns_embedded_v1_node_startrns_embedded_v1_node_stoprns_embedded_v1_node_restartrns_embedded_v1_node_get_statusrns_embedded_v1_node_sendrns_embedded_v1_node_broadcastrns_embedded_v1_node_set_log_levelrns_embedded_v1_node_subscribe_eventsrns_embedded_v1_subscription_nextrns_embedded_v1_subscription_close
The v1 structs are self-describing:
- every public struct starts with
struct_size - every public struct carries
struct_version - callers should zero-init or use the provided default-producing functions before passing structs in
Capability probe rules:
capability_schema_versionversions the meaning of the capability payload itselfknown_capability_bitsis the full bit registry this build understandscompile_time_capability_bitsis the feature set compiled into the library artifactcapability_bitsis the effective runtime-safe subset for the current build/profile- wrappers must ignore unknown bits by masking with
known_capability_bits max_blocking_timeout_ms == 0means blockingnext(timeout_ms>0)is not availabledriver_tick_target_msanddriver_tick_max_msare only non-zero in managedstdbuilds
The stable node-error registry is generated from docs/contracts/node-error-codes-v1.json and documented in docs/contracts/node-error-codes-v1.md.
Minimal Flow
- Create a node with
rns_embedded_v1_node_new(). - Probe ABI/capabilities with
rns_embedded_v1_abi_version()andrns_embedded_v1_get_capabilities(...). - Fill
RnsEmbeddedV1NodeConfigfromrns_embedded_v1_node_config_default(). - Call
rns_embedded_v1_node_start(...). - Optionally create a subscription with
rns_embedded_v1_node_subscribe_events(...). - Use
rns_embedded_v1_node_send(...)orrns_embedded_v1_node_broadcast(...). - Read
RnsEmbeddedV1PollResult+RnsEmbeddedV1NodeEventwithrns_embedded_v1_subscription_next(...). - Close subscriptions, stop the node, then free the node handle.
Example
int
Reference artifacts:
- managed host flow: std_managed_node.rs
- manual-tick runtime flow: manual_tick_runtime.rs
- mobile/wrapper FFI flow: mobile_wrapper_v1.c
Legacy Compatibility Surface
The legacy API remains available for existing firmware and bridge code:
rns_embedded_node_newrns_embedded_node_tickrns_embedded_node_push_inbound_wirerns_embedded_node_take_outbound_wirerns_embedded_node_queue_message
Use that surface when the integration owns transport progression explicitly and wants raw wire access.