Expand description
§Product OS : IO Uring
Multi-backend accept/runtime facade:
- Linux:
io_uringviatokio-uring, with optional SQPOLL, IOPOLL, and kernel-registered buffers - macOS / Windows: portable tokio (
kqueue/ IOCP) workers under the same API
This crate is not an async executor (see product-os-async-executor) and does
not depend on Flow/hyper. Higher-level HTTP servers (e.g. Product OS Router
flow_perf_native) integrate by implementing ConnectionHandler.
§Quick start
use product_os_io_uring::{
AcceptServer, BackendPreference, FnHandler, RuntimeConfig,
};
use std::net::SocketAddr;
fn main() -> Result<(), product_os_io_uring::Error> {
let config = RuntimeConfig::builder()
.workers(2)
.backend(BackendPreference::Auto)
.build();
let server = AcceptServer::new(config)?;
let addr: SocketAddr = "127.0.0.1:8080".parse().unwrap();
server.run(addr, FnHandler::new(|_stream, peer| async move {
let _ = peer;
}))
}§Feature flags
rt/net/portable/affinity/advanced— enabled by defaultbridge_tokio— convertAcceptedStreamtotokio::net::TcpStreamtracing— diagnostic logs
§Platform notes
io_uring syscalls exist only on Linux. On other OSes, BackendPreference::Auto
selects the portable tokio backend. SQPOLL/IOPOLL/registered buffers are Linux-only;
with RuntimeConfigBuilder::strict_uring_features
they error when unsupported.
Re-exports§
pub use net::AcceptServer;pub use net::AcceptedStream;pub use net::ConnectionHandler;pub use net::FnHandler;
Modules§
- net
- Networking: accept server, streams, handlers.
Structs§
- Buffer
Pool Config - Configuration for kernel-registered / provided buffers (Linux io_uring).
- CoreId
- Opaque core identifier.
- Pooled
Buffer - RAII wrapper that returns the buffer to the pool on drop.
- Registered
Buffers - Handle to buffers registered with the current io_uring runtime.
- Runtime
Config - Immutable runtime configuration.
- Runtime
Config Builder - Builder for
RuntimeConfig.
Enums§
- Backend
Kind - Resolved backend after applying platform rules.
- Backend
Preference - Preferred accept/runtime backend.
- Error
- Crate-wide error type.
Functions§
- allocate_
buffer_ vecs - Allocate buffer vectors suitable for registration without registering yet.
- apply_
uring_ builder - Build a tokio-uring builder from config (Linux).
- create_
reuseport_ listener - Create a blocking
TcpListenerbound toaddrwith reuse options. - create_
reuseport_ listener_ nonblocking - Same as
create_reuseport_listenerbut sets the socket non-blocking (tokio-friendly). - get_
buffer - Get a byte buffer with at least
capacitybytes of capacity. - get_
core_ ids - List available CPU cores, or an empty vector if affinity is disabled / unavailable.
- io_
uring_ backend_ available - Whether this build can use the io_uring backend.
- iopoll_
available - IOPOLL is a Linux io_uring setup flag (typically for
O_DIRECTworkloads). - pin_
current_ thread - Pin the current thread to
core. - registered_
buffers_ available - Kernel registered/provided buffers are Linux-only in this crate.
- return_
buf - Return a buffer to the thread-local pool.
- sqpoll_
available - SQPOLL is a Linux io_uring setup flag; availability depends on kernel/caps at runtime.
- try_
pin_ current_ thread - Pin if requested; soft-fail unless the caller needs hard errors.
Type Aliases§
- Result
- Convenient result alias.