Expand description
Rust mirror of the canonical C ABI in <nros/platform.h>.
Every nros binary links exactly one platform implementation; the
free extern "C" symbols declared below are resolved at link time.
There is no runtime registration step. To inject a platform from
C, drop a translation unit defining the symbols (or link against
a static library that does).
Rust platform crates implement the nros_platform_api traits as
before; a sibling -cffi shim crate re-exports the Rust impl as
#[unsafe(no_mangle)] extern "C" symbols matching the names in the
header. That separation lets the same Rust impl serve both
trait-driven Rust callers and C-ABI consumers.
§Usage
- C implementor: implement the functions in
<nros/platform.h>and link against the nros binary. - Rust consumer: enable the
platform-cffifeature onnros-platform;CffiPlatformdispatches every trait call to the linked C symbols.
§Companion
Platform sits one tier below RMW. The Phase 117 RMW vtable
(<nros/rmw_vtable.h>) is a runtime-pluggable struct; the
platform layer is link-time-bound free symbols. Different choice
because RMW backends genuinely swap per session (zenoh vs cyclonedds
vs xrce in the same binary at test time) while a platform is fixed
for the life of a binary.
Re-exports§
pub use crate::generated::NROS_PLATFORM_RET_ERROR;pub use crate::generated::NROS_PLATFORM_RET_INVALID;pub use crate::generated::NROS_PLATFORM_RET_NOMEM;pub use crate::generated::NROS_PLATFORM_RET_OK;pub use crate::generated::NROS_PLATFORM_RET_TIMEOUT;pub use crate::generated::NROS_PLATFORM_RET_UNSUPPORTED;pub use generated::*;
Modules§
- generated
- AUTO-GENERATED by scripts/gen-abi-bindings.sh (bindgen 0.72.1) — DO NOT EDIT.
- log
- The
LogSinkthat speaks the platform ABI.
Macros§
- nros_
platform_ export - Convenience: emit every
nros_platform_*symbol declared in<nros/platform.h>by delegating to the correspondingnros_platform_api::Platform*trait method on$ty. The caller must implement every trait covered by the capability macros. - nros_
platform_ export_ alloc - Emit
nros_platform_{alloc,realloc,dealloc}delegating to<$ty as PlatformAlloc>. - nros_
platform_ export_ clock - Emit
nros_platform_clock_{ms,us}delegating to<$ty as PlatformClock>. - nros_
platform_ export_ critical_ section - Phase 121.9 — emit the two
nros_platform_critical_section_*symbols by delegating to the caller’sPlatformCriticalSectionimpl. - nros_
platform_ export_ log - Phase 88.11 — emit
nros_platform_log_write+nros_platform_log_flushfrom aPlatformLog-implementing ZST. Use this on bare-metal / custom platforms (mps2-an385, stm32f4, esp32-baremetal, …) that don’t ship a separate C implementation file. The implementor’swritereceives the rendered body + logger name as&[u8]slices. - nros_
platform_ export_ net - Emit every
nros_platform_tcp_*/nros_platform_udp_*/nros_platform_udp_mcast_*/nros_platform_socket_*/nros_platform_network_pollsymbol declared in<nros/platform_net.h>by delegating to the corresponding trait method on$ty. The caller must implementPlatformTcp,PlatformUdp,PlatformUdpMulticast,PlatformSocketHelpers, andPlatformNetworkPoll. - nros_
platform_ export_ panic - Emit
nros_platform_panicdelegating to<$ty as PlatformPanic>(phase-366 / RFC-0077). - nros_
platform_ export_ random - Emit
nros_platform_random_*delegating to<$ty as PlatformRandom>. - nros_
platform_ export_ sleep - Emit
nros_platform_sleep_{us,ms,s}delegating to<$ty as PlatformSleep>. - nros_
platform_ export_ threading - Emit
nros_platform_task_*,nros_platform_mutex_*,nros_platform_mutex_rec_*, andnros_platform_condvar_*delegating to<$ty as PlatformThreading>. Skip this macro on platforms without kernel threads. - nros_
platform_ export_ time - Emit
nros_platform_time_*delegating to<$ty as PlatformTime>. - nros_
platform_ export_ timer - Emit every
nros_platform_timer_*symbol declared in<nros/platform_timer.h>by delegating to the correspondingPlatformTimertrait method on$ty. - nros_
platform_ export_ yield - Emit
nros_platform_yield_nowdelegating to<$ty as PlatformYield>.
Structs§
- Cffi
Platform - Zero-sized type implementing the platform traits via the canonical
nros_platform_*C symbols. - Cffi
Timer Handle
Type Aliases§
- Nros
Platform LogFlush Fn - Board-supplied flush fn type. Pass
Nonetonros_platform_register_log_writerwhen the writer is fully synchronous. - Nros
Platform LogWriter Fn - Board-supplied writer fn type. ONLY meaningful on platforms whose
nros_platform_log_writeimpl is itself a thin dispatcher to a board-registered fn (FreeRTOS, ThreadX, bare-metal). On platforms with a native logger (POSIX, Zephyr, ESP-IDF, NuttX), the symbol is absent and the board should not link against it. - Nros
Platform Ret - The C
nros_platform_ret_t, from the generated bindings.