Skip to main content

nros_transport_ops_s

Struct nros_transport_ops_s 

Source
#[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: u32

ABI version. MUST equal NROS_TRANSPORT_OPS_ABI_VERSION_V1. Any other value is rejected at registration time with NROS_RMW_RET_INCOMPATIBLE_ABI.

§_reserved: u32

Reserved padding for alignment stability across appends. Set to zero.

§user_data: *mut c_void

Opaque 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

Source§

fn clone(&self) -> nros_transport_ops_s

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for nros_transport_ops_s

Source§

impl Debug for nros_transport_ops_s

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.