Skip to main content

Crate product_os_io_uring

Crate product_os_io_uring 

Source
Expand description

§Product OS : IO Uring

Multi-backend accept/runtime facade:

  • Linux: io_uring via tokio-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 default
  • bridge_tokio — convert AcceptedStream to tokio::net::TcpStream
  • tracing — 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§

BufferPoolConfig
Configuration for kernel-registered / provided buffers (Linux io_uring).
CoreId
Opaque core identifier.
PooledBuffer
RAII wrapper that returns the buffer to the pool on drop.
RegisteredBuffers
Handle to buffers registered with the current io_uring runtime.
RuntimeConfig
Immutable runtime configuration.
RuntimeConfigBuilder
Builder for RuntimeConfig.

Enums§

BackendKind
Resolved backend after applying platform rules.
BackendPreference
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 TcpListener bound to addr with reuse options.
create_reuseport_listener_nonblocking
Same as create_reuseport_listener but sets the socket non-blocking (tokio-friendly).
get_buffer
Get a byte buffer with at least capacity bytes 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_DIRECT workloads).
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.