Safe Rust bindings for Apple's
Network.framework,
the modern (10.14+) replacement for BSD sockets / CFNetwork / NSStream.
v0.8 covers:
TcpClient,TcpListener,UdpClient,QuicConnection,WebSocket,Browser, andPathMonitor.ConnectionParametersfor advanced protocol-stack configuration.ContentContextfor per-message priority, expiration, antecedents, and protocol metadata.- Custom protocol framers via
FramerDefinition,Framer,FramerContext, andFramerMessage. ConnectionGroup/ConnectionGroupDescriptorfor multicast and multiplex groups.- Interface enumeration via
list_interfaces()andPathMonitor::list_interfaces(). PrivacyContext,ProxyConfig, andResolverConfigfor proxy and encrypted-DNS policy.
Built using a thin C shim around Apple's block-based nw_* C API; no
Objective-C runtime, no Swift bridge required.
std::net calls BSD sockets directly, which works but bypasses macOS's
modern network stack (cellular fallback, Wi-Fi assist, Network
Extensions, secure DNS, multipath, on-device proxying). Apps shipped
via the Mac App Store must use Network.framework for many of those
behaviours. This crate provides a tiny safe surface for that.
The crate now covers most publicly useful Network.framework surfaces. Remaining
work is focused on deeper protocol metadata helpers, richer connection-group
operations such as extraction / reinsertion, and additional low-level protocol
options.
use networkframework::TcpClient;
let client = TcpClient::connect("example.com", 80)?;
client.send(b"GET / HTTP/1.0\r\nHost: example.com\r\n\r\n")?;
let response = client.receive(8192)?;
println!("got {} bytes", response.len());
# Ok::<_, networkframework::NetworkError>(())cargo run --example framer_length_prefixcargo run --example interface_listcargo run --example connection_groupcargo run --example 03_udp_and_path