Skip to main content

PlatformUdp

Trait PlatformUdp 

Source
pub trait PlatformUdp {
    // Required methods
    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;
    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;
    fn set_recv_timeout(sock: *const c_void, timeout_ms: u32);

    // Provided methods
    fn readiness_handle(_sock: *const c_void) -> i32 { ... }
    fn set_rx_notify(
        _sock: *const c_void,
        _notify: Option<unsafe extern "C" fn(*mut c_void)>,
        _ctx: *mut c_void,
    ) -> i8 { ... }
    fn listen(
        _sock: *mut c_void,
        _endpoint: *const c_void,
        _timeout_ms: u32,
    ) -> i8 { ... }
}
Expand description

UDP unicast networking.

Required Methods§

Source

fn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8

Source

fn free_endpoint(ep: *mut c_void)

Source

fn open(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8

Source

fn close(sock: *mut c_void)

Source

fn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize

Source

fn read_exact(sock: *const c_void, buf: *mut u8, len: usize) -> usize

Source

fn send( sock: *const c_void, buf: *const u8, len: usize, endpoint: *const c_void, ) -> usize

Source

fn set_recv_timeout(sock: *const c_void, timeout_ms: u32)

Set the receive timeout on a UDP socket (milliseconds). 0 means block indefinitely (no timeout).

Provided Methods§

Source

fn readiness_handle(_sock: *const c_void) -> i32

phase-521 W4 (RFC-0113 D4) — the OS handle that becomes readable when a datagram arrives: a file descriptor on POSIX and NuttX.

Default -1: this stack has no such handle, and its sessions report readiness as a Notify instead.

Source

fn set_rx_notify( _sock: *const c_void, _notify: Option<unsafe extern "C" fn(*mut c_void)>, _ctx: *mut c_void, ) -> i8

phase-521 W4 (RFC-0113 D4) — install (Some) or remove (None) the socket’s receive notification, called from the stack’s own context each time a datagram is queued, so it must only signal.

Default -1: this stack has no such hook.

Source

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.

Optional — the default returns -1, which the shim forwards to _z_listen_udp_unicast as “not implemented”. Platforms that need UDP server sockets (e.g. for running an XRCE-DDS agent locally) should override this. Once Phase 84.F4 lands (the “platform traits become a real contract” refactor), the shim will dispatch through this trait method automatically.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PlatformUdp for CffiPlatform

Source§

fn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8

Source§

fn free_endpoint(ep: *mut c_void)

Source§

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

Source§

fn close(sock: *mut c_void)

Source§

fn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize

Source§

fn read_exact(sock: *const c_void, buf: *mut u8, len: usize) -> usize

Source§

fn send( sock: *const c_void, buf: *const u8, len: usize, endpoint: *const c_void, ) -> usize

Source§

fn set_recv_timeout(sock: *const c_void, timeout_ms: u32)

Source§

fn readiness_handle(sock: *const c_void) -> i32

Source§

fn set_rx_notify( sock: *const c_void, notify: Option<unsafe extern "C" fn(*mut c_void)>, ctx: *mut c_void, ) -> i8

Implementors§