Expand description
Platform capability sub-traits for nros.
This crate exists to break the dependency cycle between
nros-platform (which depends on every platform crate via its
feature-gated ConcretePlatform resolver) and the platform crates
themselves (which need to implement these traits on their ZSTs).
It contains only trait definitions — no implementations, no
dependencies — so platform crates can take a build-time dep on it
without creating a cycle back through nros-platform.
nros-platform re-exports everything from this crate, so downstream
code that writes use nros_platform::PlatformClock; continues to
work unchanged.
Each trait covers an independent system capability. Platform implementations pick which traits to implement based on what the hardware/RTOS provides. RMW shim crates declare trait bounds for the capabilities they need.
§Naming convention
Method names drop redundant prefixes when the trait name already
supplies the namespace — e.g., PlatformTcp::open rather than
PlatformTcp::tcp_open. Dispatch is always through a qualified
path (<ConcretePlatform as PlatformTcp>::open(...)), so
trait-to-trait collisions (PlatformTcp::open vs PlatformUdp::open)
are disambiguated at the call site without needing a prefix on the
trait method itself.
Three categories still keep sub-namespace prefixes internally:
PlatformThreading—mutex_*,condvar_*,task_*because the trait bundles three independent primitive families and unprefixedinit/dropwould be ambiguous within the trait itself.PlatformUdpMulticast—mcast_*because these methods have different signatures fromPlatformUdp’s same-name methods; keeping the prefix makes call sites that use both traits self-documenting.- The
closemethod appears on bothPlatformTcpandPlatformSocketHelpers— the first is TCP teardown, the second is zenoh-pico’s generic “shutdown + close” helper. Both live unprefixed in their respective traits; call sites disambiguate via the qualified path.
§Status (Phase 84.F4)
The platform ZSTs (PosixPlatform, ZephyrPlatform, etc.) do not
currently implement these traits — every platform exposes its methods
as inherent impl Platform { fn foo() {} } blocks, and shim crates
dispatch by name match. 84.F4 migrates each platform to impl PlatformX for Platform { fn foo() {} } one trait at a time, with the
shims switching to <P as PlatformX>::foo(). Until that work is
complete the traits here are a target specification.
Re-exports§
pub use wake::WAKE_STORAGE_ALIGN;pub use wake::WAKE_STORAGE_BYTES;pub use wake::Wake;pub use wake::WakeInitError;pub use wake::WakeReason;
Modules§
- wake
- Phase 130 — ergonomic Rust wrapper around
PlatformThreading’s wake primitive. - xorshift32
- Xorshift32 PRNG helpers shared by RTOS platform crates that lack a hardware RNG.
Enums§
- Sched
Error - Errors returned by
PlatformSchedulerentry points. - Sched
Policy - Per-thread OS scheduling policy.
- Timer
Error - Errors returned by
PlatformTimerentry points.
Traits§
- Platform
Alloc - Heap memory allocation.
- Platform
Clock - Monotonic clock.
- Platform
Critical Section - Global mutual exclusion against preemption + ISR delivery (Phase 121.9).
- Platform
Ivc - Inter-processor mailbox transport, modelled after NVIDIA Tegra IVC.
- Platform
Libc - Standard C library functions needed by zenoh-pico on bare-metal targets.
- Platform
Log - Per-platform leveled log delivery.
- Platform
Network Poll - Network poll callback for bare-metal platforms using smoltcp.
- Platform
Random - Pseudo-random number generation.
- Platform
Scheduler - Platform
Serial - Serial (byte-stream) transport.
- Platform
Sleep - Sleep primitives.
- Platform
Socket Helpers - Socket helper operations called by zenoh-pico’s transport layer.
- Platform
Tcp - TCP networking.
- Platform
Threading - Threading primitives: tasks, mutexes, and condition variables.
- Platform
Time - Wall-clock / system time.
- Platform
Timer - Periodic timer for ISR-driven sporadic-server budget refill
(Phase 110.E.b). The trait factors out the per-platform timer
surface so the executor (
nros-node) can register an atomic refill callback without becoming generic over the platform — seedocs/design/0017-platform-timer.md. - Platform
Udp - UDP unicast networking.
- Platform
UdpMulticast - UDP multicast networking (used for zenoh scouting on desktop platforms).
- Platform
Yield - Scheduler yield primitive.