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 method
    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 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", so this trait is not object safe.

Implementors§