Pure-Rust ZeroMQ. Wire-compatible with libzmq.
omq is a thin facade that re-exports a backend chosen at build
time. The default compio-backend feature pulls in
omq-compio, a
single-thread io_uring (Linux), IOCP (Windows), or kqueue (macOS)
runtime; the alternative
tokio-backend feature swaps in
omq-tokio, a multi-thread
mio/tokio runtime. The two are mutually exclusive — enabling
both is a compile error. The public Socket / Endpoint /
Options / Message API is identical either way, verified in
lockstep by per-backend coverage_matrix test suites plus a
cross-runtime interop_compio ZMTP-on-the-wire test in the
repository.
Example
# async fn run() -> Result<(), Box<dyn std::error::Error>> {
use omq::{Endpoint, Message, Options, Socket, SocketType};
let pull = Socket::new(SocketType::Pull, Options::default());
pull.bind("tcp://127.0.0.1:5555".parse()?).await?;
let push = Socket::new(SocketType::Push, Options::default());
push.connect("tcp://127.0.0.1:5555".parse()?).await?;
push.send(Message::single("hi")).await?;
let m = pull.recv().await?;
assert_eq!(m.parts()[0].as_bytes(), &b"hi"[..]);
# Ok(()) }
Picking a backend
# Default: compio (io_uring on Linux, IOCP on Windows, kqueue on
# macOS). Single-thread by design — instantiate one runtime per
# core for thread-per-core.
[]
= "0"
# Alternative: tokio (multi-thread by default).
[]
= { = "0", = false, = ["tokio-backend"] }
Cargo features
All optional, all opt-in:
compio-backend— (default) compio runtime backend.tokio-backend— tokio runtime backend (mutually exclusive with compio).curve— CURVE encrypted-handshake mechanism (RFC 26).blake3zmq— omq-native AEAD (X25519 + BLAKE3 + ChaCha20).lz4—lz4+tcp://compression transport.zstd—zstd+tcp://compression transport.priority— strict per-pipe priority onSocket::connect_with.
See BENCHMARKS.md for throughput / latency tables.