pub struct CffiPlatform;Expand description
Zero-sized type implementing the platform traits via the canonical
nros_platform_* C symbols.
The crate that pulls CffiPlatform into a final binary is
responsible for ensuring the symbols are supplied at link time
(either by a C translation unit or a Rust -cffi shim crate).
Trait Implementations§
Source§impl PlatformAlloc for CffiPlatform
impl PlatformAlloc for CffiPlatform
Source§fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void
fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void
Reallocate a previously allocated block. Returns null on failure.
Source§fn heap_used_bytes() -> usize
fn heap_used_bytes() -> usize
Phase 230 Z5 / RFC-0034 D7 — bytes currently allocated from the
platform heap. The true unified figure where the platform owns one
kernel heap shared by the C side (
alloc) and the Rust
#[global_allocator]. Default 0 = “unknown / not instrumented”.Source§fn heap_total_bytes() -> usize
fn heap_total_bytes() -> usize
Total managed heap size in bytes (used + free), or
0 if unknown.Source§impl PlatformClock for CffiPlatform
impl PlatformClock for CffiPlatform
Source§impl PlatformCriticalSection for CffiPlatform
impl PlatformCriticalSection for CffiPlatform
Source§fn acquire() -> u32
fn acquire() -> u32
Enter a critical section. Returns an opaque token to pass to
Self::release.Source§fn release(token: u32)
fn release(token: u32)
Leave a critical section, restoring the posture captured at
Self::acquire.Source§impl PlatformLog for CffiPlatform
impl PlatformLog for CffiPlatform
Source§impl PlatformNetworkPoll for CffiPlatform
impl PlatformNetworkPoll for CffiPlatform
Source§fn network_poll()
fn network_poll()
Poll the network stack to process pending I/O. Read more
Source§impl PlatformRandom for CffiPlatform
impl PlatformRandom for CffiPlatform
Source§impl PlatformScheduler for CffiPlatform
impl PlatformScheduler for CffiPlatform
Source§fn yield_now()
fn yield_now()
Cooperative yield. Same semantics as
PlatformYield::yield_now; mirrored here so consumers don’t
need to import both traits when only the scheduler control
surface is in scope. Default is a core::hint::spin_loop().Source§fn set_current_thread_policy(_p: SchedPolicy) -> Result<(), SchedError>
fn set_current_thread_policy(_p: SchedPolicy) -> Result<(), SchedError>
Apply the requested policy to the calling thread. Read more
Source§fn set_affinity(_cpu_mask: u32) -> Result<(), SchedError>
fn set_affinity(_cpu_mask: u32) -> Result<(), SchedError>
Pin the calling thread to the CPUs whose bit is set in
cpu_mask. Default returns SchedError::Unsupported —
platforms with affinity APIs override.Source§impl PlatformSleep for CffiPlatform
impl PlatformSleep for CffiPlatform
Source§impl PlatformSocketHelpers for CffiPlatform
impl PlatformSocketHelpers for CffiPlatform
Source§impl PlatformTcp for CffiPlatform
impl PlatformTcp for CffiPlatform
Source§fn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8
fn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8
Resolve address + port strings into an endpoint handle.
Source§fn free_endpoint(ep: *mut c_void)
fn free_endpoint(ep: *mut c_void)
Free endpoint resources.
Source§fn open(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
fn open(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
Open a TCP client connection.
endpoint is by-value (opaque bytes on stack).Source§fn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize
fn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize
Read up to
len bytes. Returns bytes read, or usize::MAX on error.Source§impl PlatformThreading for CffiPlatform
impl PlatformThreading for CffiPlatform
Source§fn task_init(
task: *mut c_void,
attr: *mut c_void,
entry: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
arg: *mut c_void,
) -> i8
fn task_init( task: *mut c_void, attr: *mut c_void, entry: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>, arg: *mut c_void, ) -> i8
Spawn a new task.
task is opaque caller-provided storage;
attr carries scheduling hints (priority, stack size) or
null for defaults; entry is the task entry point; arg
is forwarded to entry. Returns 0 on success, non-zero
on failure.Source§fn task_join(task: *mut c_void) -> i8
fn task_join(task: *mut c_void) -> i8
Block until
task exits. Cleans up the task storage on
success.Source§fn task_detach(task: *mut c_void) -> i8
fn task_detach(task: *mut c_void) -> i8
Mark
task as detached — its storage is reclaimed on exit
without a join.Source§fn task_cancel(task: *mut c_void) -> i8
fn task_cancel(task: *mut c_void) -> i8
Request
task to terminate at the next cancellation point.
Cooperative.Source§fn mutex_init(m: *mut c_void) -> i8
fn mutex_init(m: *mut c_void) -> i8
Initialise a non-recursive mutex in caller-provided storage.
Source§fn mutex_rec_init(m: *mut c_void) -> i8
fn mutex_rec_init(m: *mut c_void) -> i8
Initialise a recursive mutex (same-thread re-entrancy
permitted). Required by zenoh-pico.
Source§fn mutex_rec_try_lock(m: *mut c_void) -> i8
fn mutex_rec_try_lock(m: *mut c_void) -> i8
Try to lock; same re-entry semantics as
mutex_rec_lock.Source§fn mutex_rec_unlock(m: *mut c_void) -> i8
fn mutex_rec_unlock(m: *mut c_void) -> i8
Unlock; releases when the lock count returns to zero.
Source§fn condvar_init(cv: *mut c_void) -> i8
fn condvar_init(cv: *mut c_void) -> i8
Initialise a condition variable in caller-provided storage.
Source§fn condvar_signal_from_isr(cv: *mut c_void) -> i8
fn condvar_signal_from_isr(cv: *mut c_void) -> i8
Phase 124.B.7.a — ISR-safe variant of
Self::condvar_signal.
Callable from interrupt / signal-handler context. Backends
implement via async-signal-safe primitives (POSIX:
eventfd write forwarded by a worker thread; RTOS:
xSemaphoreGiveFromISR, tx_event_flags_set from ISR,
k_sem_give from ISR). Returns non-zero when the backend
has no ISR-safe path — caller can fall back to
condvar_signal (with the obvious latency cost). Read moreSource§fn condvar_wait(cv: *mut c_void, m: *mut c_void) -> i8
fn condvar_wait(cv: *mut c_void, m: *mut c_void) -> i8
Atomically release
m and block on cv. The mutex is
re-acquired before this function returns.Source§fn condvar_wait_until(cv: *mut c_void, m: *mut c_void, abstime: u64) -> i8
fn condvar_wait_until(cv: *mut c_void, m: *mut c_void, abstime: u64) -> i8
Wait with absolute monotonic deadline (milliseconds since
the
PlatformClock::clock_ms epoch). Returns non-zero on
timeout.Source§fn wake_init(w: *mut c_void) -> i8
fn wake_init(w: *mut c_void) -> i8
Initialise a binary-semaphore-shaped wake primitive in
caller-provided storage. See
<nros/platform.h> for the
per-platform backing primitive (POSIX sem_t, Zephyr
k_sem, FreeRTOS xSemaphoreBinary, …). Default returns
-1 (unsupported).Source§fn wake_drop(w: *mut c_void) -> i8
fn wake_drop(w: *mut c_void) -> i8
Tear down a wake primitive. Default returns
-1
(unsupported).Source§fn wake_wait_ms(w: *mut c_void, timeout_ms: u32) -> i8
fn wake_wait_ms(w: *mut c_void, timeout_ms: u32) -> i8
Block until signaled or
timeout_ms elapses. Returns 0 on
signal, 1 on timeout, -1 on error. Default returns -1
(unsupported).Source§fn wake_signal(w: *mut c_void) -> i8
fn wake_signal(w: *mut c_void) -> i8
Wake one waiter. Idempotent — a signal pending when another
arrives is coalesced (the primitive stays at value 1).
Default returns
-1 (unsupported).Source§fn wake_signal_from_isr(w: *mut c_void) -> i8
fn wake_signal_from_isr(w: *mut c_void) -> i8
ISR-safe signal. Returns
-1 when the backend has no ISR
path; callers may fall back to wake_signal (with the
obvious latency cost). Default forwards to wake_signal.Source§fn wake_storage_size() -> usize
fn wake_storage_size() -> usize
Caller-storage size requirement (bytes). Default
0 —
signals “no wake primitive available”. May be called before
wake_init.Source§fn wake_storage_align() -> usize
fn wake_storage_align() -> usize
Caller-storage alignment requirement (bytes). Default
1.Source§impl PlatformTime for CffiPlatform
impl PlatformTime for CffiPlatform
Source§fn time_now_ms() -> u64
fn time_now_ms() -> u64
Returns system time in milliseconds.
Source§fn time_since_epoch_secs() -> u32
fn time_since_epoch_secs() -> u32
Seconds component of wall-clock time since the Unix epoch.
Source§fn time_since_epoch_nanos() -> u32
fn time_since_epoch_nanos() -> u32
Sub-second nanoseconds component of wall-clock time since the
Unix epoch (i.e. the nanosecond remainder after the seconds are
stripped; always in
0..1_000_000_000).Source§impl PlatformTimer for CffiPlatform
impl PlatformTimer for CffiPlatform
Source§type TimerHandle = CffiTimerHandle
type TimerHandle = CffiTimerHandle
Opaque per-platform handle (FreeRTOS
TimerHandle_t,
Zephyr *mut k_timer, ThreadX *mut TX_TIMER, POSIX
timer_t). Must be Send + Sync + 'static so the executor
can stash it across thread boundaries.Source§fn create_periodic(
period_us: u32,
callback: extern "C" fn(*mut c_void),
user_data: *mut c_void,
) -> Result<Self::TimerHandle, TimerError>
fn create_periodic( period_us: u32, callback: extern "C" fn(*mut c_void), user_data: *mut c_void, ) -> Result<Self::TimerHandle, TimerError>
Register a periodic timer that fires
callback(user_data)
every period_us microseconds. Returns the platform-native
handle for later destruction. Read moreSource§fn create_oneshot(
timeout_us: u32,
callback: extern "C" fn(*mut c_void),
user_data: *mut c_void,
) -> Result<Self::TimerHandle, TimerError>
fn create_oneshot( timeout_us: u32, callback: extern "C" fn(*mut c_void), user_data: *mut c_void, ) -> Result<Self::TimerHandle, TimerError>
Phase 110.E.b follow-up — register a one-shot timer that
fires
callback(user_data) exactly once after timeout_us
microseconds. Used by per-callback runtime measurement: arm
just before dispatch with timeout_us = budget_us; on
callback completion call cancel. If the timer fires first
the callback overran its budget. Read moreSource§fn destroy(handle: Self::TimerHandle)
fn destroy(handle: Self::TimerHandle)
Cancel + free the timer. Idempotent on already-destroyed
handles. Must drain in-flight callback invocations before
returning so the user_data pointer is no longer accessed.
Source§fn cancel(handle: &mut Self::TimerHandle) -> bool
fn cancel(handle: &mut Self::TimerHandle) -> bool
Phase 110.E.b follow-up — cancel a previously-armed oneshot
timer. Returns
true when the cancellation prevented the
callback from firing, false when the callback already
fired (or the timer was already cancelled). Default is a
no-op returning false.Source§impl PlatformUdp for CffiPlatform
impl PlatformUdp for CffiPlatform
fn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8
fn free_endpoint(ep: *mut c_void)
fn open(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
Source§fn listen(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
fn listen(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
Open a UDP socket in listen (server) mode, bound to the given
endpoint. Returns 0 on success, negative on failure. Read more
fn close(sock: *mut c_void)
fn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize
fn read_exact(sock: *const c_void, buf: *mut u8, len: usize) -> usize
fn send( sock: *const c_void, buf: *const u8, len: usize, endpoint: *const c_void, ) -> usize
Source§impl PlatformUdpMulticast for CffiPlatform
impl PlatformUdpMulticast for CffiPlatform
fn mcast_open( sock: *mut c_void, endpoint: *const c_void, lep: *mut c_void, timeout_ms: u32, iface: *const u8, ) -> i8
fn mcast_listen( sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32, iface: *const u8, join: *const u8, ) -> i8
fn mcast_close( sockrecv: *mut c_void, socksend: *mut c_void, rep: *const c_void, lep: *const c_void, )
fn mcast_read( sock: *const c_void, buf: *mut u8, len: usize, lep: *const c_void, addr: *mut c_void, ) -> usize
fn mcast_read_exact( sock: *const c_void, buf: *mut u8, len: usize, lep: *const c_void, addr: *mut c_void, ) -> usize
fn mcast_send( sock: *const c_void, buf: *const u8, len: usize, endpoint: *const c_void, ) -> usize
Source§impl PlatformYield for CffiPlatform
impl PlatformYield for CffiPlatform
Auto Trait Implementations§
impl Freeze for CffiPlatform
impl RefUnwindSafe for CffiPlatform
impl Send for CffiPlatform
impl Sync for CffiPlatform
impl Unpin for CffiPlatform
impl UnsafeUnpin for CffiPlatform
impl UnwindSafe for CffiPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more