#[repr(C)]pub struct nros_transport_ops_s {
pub abi_version: u32,
pub _reserved: u32,
pub user_data: *mut c_void,
pub open: Option<unsafe extern "C" fn(user_data: *mut c_void, params: *const c_void) -> i32>,
pub close: Option<unsafe extern "C" fn(user_data: *mut c_void)>,
pub write: Option<unsafe extern "C" fn(user_data: *mut c_void, buf: *const u8, len: usize) -> i32>,
pub read: Option<unsafe extern "C" fn(user_data: *mut c_void, buf: *mut u8, len: usize, timeout_ms: u32) -> i32>,
}Expand description
Runtime-pluggable custom transport. The runtime never
dereferences user_data; it’s the caller’s per-transport
context, threaded back into every callback’s first argument.
THIS declaration is the ABI single source of truth (RFC-0054): Rust
consumes the committed bindgen output of this header, and
nros_rmw::NrosTransportOps is the hand-written Rust-side view kept in
lockstep with it — not the other way round. The previous wording had that
backwards (issue 0331). Layout equivalence is asserted on both sides: see
nros_transport_ops_t in nros-rmw-cffi/tests/c_stubs/abi_layout_check.c
and the const _ size/align block beside
nros_rmw_cffi_set_custom_transport in nros-rmw-cffi/src/lib.rs. Same
layout, same threading contract, same return codes.
Fields§
§abi_version: u32ABI version. MUST equal NROS_TRANSPORT_OPS_ABI_VERSION_V1.
Any other value is rejected at registration time with
NROS_RMW_RET_INCOMPATIBLE_ABI.
_reserved: u32Reserved padding for alignment stability across appends. Set to zero.
user_data: *mut c_voidOpaque caller context, threaded back into every callback.
Lifetime: must outlive the transport’s active period
(i.e. until close returns).
open: Option<unsafe extern "C" fn(user_data: *mut c_void, params: *const c_void) -> i32>Open the underlying medium.
@param user_data Caller-supplied context.
@param params Opaque per-transport metadata (e.g. UART baud
rate, USB-CDC endpoint id). May be NULL.
@retval NROS_RMW_RET_OK on success.
@retval <0 on failure (any rmw_ret_t error code).
close: Option<unsafe extern "C" fn(user_data: *mut c_void)>Tear the transport down. After close returns, the runtime
will not invoke read or write on this transport unless
nros_set_custom_transport is called again.
write: Option<unsafe extern "C" fn(user_data: *mut c_void, buf: *const u8, len: usize) -> i32>Send len bytes from buf. Must NOT block beyond a brief
hardware retry; long blocking should surface as
NROS_RMW_RET_TIMEOUT.
@retval NROS_RMW_RET_OK on success.
@retval <0 on failure (any rmw_ret_t error code).
read: Option<unsafe extern "C" fn(user_data: *mut c_void, buf: *mut u8, len: usize, timeout_ms: u32) -> i32>Receive up to len bytes into buf within timeout_ms.
@retval >=0 number of bytes read (may be less than len).
@retval <0 on error / timeout (any rmw_ret_t error
code).
Trait Implementations§
Source§impl Clone for nros_transport_ops_s
impl Clone for nros_transport_ops_s
Source§fn clone(&self) -> nros_transport_ops_s
fn clone(&self) -> nros_transport_ops_s
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more