pub trait PlatformTcp {
// 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 listen(sock: *mut c_void, endpoint: *const c_void) -> 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) -> usize;
}Expand description
TCP networking.
Socket and endpoint parameters are opaque *mut c_void pointers to
platform-specific types (_z_sys_net_socket_t, _z_sys_net_endpoint_t).
The shim provides correctly-sized #[repr(C)] wrappers whose sizes are
auto-detected from C headers at build time (see Phase 80 design).
Read functions return usize::MAX on error. Send returns usize::MAX on error.
Method names are unprefixed — the trait already namespaces them. Shims
dispatch via <ConcretePlatform as PlatformTcp>::open(...) etc.
Required Methods§
Sourcefn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8
fn create_endpoint(ep: *mut c_void, address: *const u8, port: *const u8) -> i8
Resolve address + port strings into an endpoint handle.
Sourcefn free_endpoint(ep: *mut c_void)
fn free_endpoint(ep: *mut c_void)
Free endpoint resources.
Sourcefn open(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
fn open(sock: *mut c_void, endpoint: *const c_void, timeout_ms: u32) -> i8
Open a TCP client connection. endpoint is by-value (opaque bytes on stack).
Sourcefn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize
fn read(sock: *const c_void, buf: *mut u8, len: usize) -> usize
Read up to len bytes. Returns bytes read, or usize::MAX on error.
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.