pub trait PlatformLibc {
// Required methods
fn strlen(s: *const u8) -> usize;
fn strcmp(s1: *const u8, s2: *const u8) -> c_int;
fn strncmp(s1: *const u8, s2: *const u8, n: usize) -> c_int;
fn strchr(s: *const u8, c: c_int) -> *mut u8;
fn strncpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8;
fn memcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void;
fn memmove(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void;
fn memset(dest: *mut c_void, c: c_int, n: usize) -> *mut c_void;
fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) -> c_int;
fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_void;
fn strtoul(nptr: *const u8, endptr: *mut *mut u8, base: c_int) -> c_ulong;
fn errno_ptr() -> *mut c_int;
}Expand description
Standard C library functions needed by zenoh-pico on bare-metal targets.
Platforms with a C runtime (RTOS, POSIX) do NOT need to implement this.
§Dispatch model (Phase 84.F4.6)
This trait is documentary only — it is NOT dispatched through by
zpico-platform-shim or xrce-platform-shim. The C libraries resolve
these symbols (strlen, memcpy, errno, …) at link time directly
from #[unsafe(no_mangle)] extern "C" fn definitions in
nros-baremetal-common, which bare-metal platform crates pull in
via the libc-stubs feature:
nros-baremetal-common = { ..., features = ["libc-stubs"] }The trait is retained in this API surface so that a future shim
refactor could route libc through typed Rust methods without
changing consumers. Today, implementing PlatformLibc on a platform
ZST would be pure documentation; the actual contract — “the linker
can resolve strlen etc.” — is enforced at link time, not at
compile time. No platform crate implements this trait in the
current tree.
Required Methods§
fn strlen(s: *const u8) -> usize
fn strcmp(s1: *const u8, s2: *const u8) -> c_int
fn strncmp(s1: *const u8, s2: *const u8, n: usize) -> c_int
fn strchr(s: *const u8, c: c_int) -> *mut u8
fn strncpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8
fn memcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void
fn memmove(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void
fn memset(dest: *mut c_void, c: c_int, n: usize) -> *mut c_void
fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) -> c_int
fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_void
fn strtoul(nptr: *const u8, endptr: *mut *mut u8, base: c_int) -> c_ulong
fn errno_ptr() -> *mut c_int
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.