Skip to main content

NrosTransportOps

Struct NrosTransportOps 

Source
#[repr(C)]
pub struct NrosTransportOps { pub abi_version: u32, pub _reserved: u32, pub user_data: *mut c_void, pub open: unsafe extern "C" fn(user_data: *mut c_void, params: *const c_void) -> i32, pub close: unsafe extern "C" fn(user_data: *mut c_void), pub write: unsafe extern "C" fn(user_data: *mut c_void, buf: *const u8, len: usize) -> i32, pub read: unsafe extern "C" fn(user_data: *mut c_void, buf: *mut u8, len: usize, timeout_ms: u32) -> i32, }
Expand description

Phase 115.A — runtime-pluggable custom transport. Caller fills in the four fn pointers, hands the struct to set_custom_transport, and the active backend treats it as the read / write surface for every wire frame.

#[repr(C)] so this is the SAME struct that nros_transport_ops_t (C) and nros::TransportOps (C++) point at — single layout, no parallel definitions to drift.

§Return-code conventions

open / write return NROS_RMW_RET_OK (== 0) on success and a negative nros_ret_t (see nros-rmw-cffi) on failure. read returns the non-negative byte count on success or a negative nros_ret_t on error / timeout.

§Safety contract for the four fn pointers

  • All callbacks receive user_data as their first argument. The pointer is whatever the caller stored at registration time; the runtime never dereferences it.
  • buf / len describe a contiguous byte region the callback may read (write) or write (read). The callback must NOT retain pointers across the call.
  • params (in open) is opaque per-transport metadata threaded through from set_custom_transport. May be NULL.

Fields§

§abi_version: u32

Phase 115.A.2 — ABI version. Consumers MUST fill in NROS_TRANSPORT_OPS_ABI_VERSION_V1; mismatched values are rejected at registration time with TransportError::IncompatibleAbi (NROS_RMW_RET_INCOMPATIBLE_ABI at the C boundary). Reserved for future minor-version detection — see the const’s doc-comment.

§_reserved: u32

Phase 115.A.2 — reserved padding to keep the struct alignment-stable across appends. Must be zero.

§user_data: *mut c_void

Opaque caller context, threaded back into every callback as the first argument. Lifetime: must outlive the transport’s active period (i.e. until close returns).

§open: unsafe extern "C" fn(user_data: *mut c_void, params: *const c_void) -> i32

Open the underlying medium. params is opaque per-transport metadata (e.g. UART baud rate, USB-CDC endpoint id) supplied at registration time.

§close: unsafe extern "C" fn(user_data: *mut c_void)

Tear the transport down. Complement of open. After close returns, the runtime will not invoke read or write on this transport unless set_custom_transport is called again.

§write: unsafe extern "C" fn(user_data: *mut c_void, buf: *const u8, len: usize) -> i32

Send len bytes from buf. Returns 0 on success, negative nros_ret_t on failure. Must NOT block beyond a brief hardware retry; long blocking should surface as NROS_RMW_RET_TIMEOUT (-2).

§read: 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. Returns the non-negative byte count on success (may be less than len), or a negative nros_ret_t on error / timeout.

Trait Implementations§

Source§

impl Clone for NrosTransportOps

Source§

fn clone(&self) -> NrosTransportOps

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for NrosTransportOps

Source§

impl Send for NrosTransportOps

Source§

impl Sync for NrosTransportOps

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.