rustzmq2 0.1.0

A native async Rust implementation of ZeroMQ
Documentation

rustzmq2

A native async Rust implementation of ZeroMQ.

Crates.io docs.rs CI Bench License

Send and receive messages across processes, machines, and languages using ZeroMQ — in pure async Rust, with no libzmq or libsodium dependency. Runs on tokio or smol; supports the full ZMTP security stack (PLAIN, CURVE, ZAP). Performance is on par with libzmq, with a meaningful edge on high-fanout PUB/XPUB workloads — see the live head-to-head comparison (or docs/BENCHMARKS.md for methodology).

Quick start

[dependencies]
rustzmq2 = "0.1"
tokio = { version = "1", features = ["full"] }
// server
use rustzmq2::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut rep = rustzmq2::RepSocket::builder()
        .receive_timeout(std::time::Duration::from_secs(30))
        .build();
    rep.bind("tcp://127.0.0.1:5555").await?;
    loop {
        let msg: String = rep.recv().await?.try_into()?;
        rep.send(format!("{msg} reply").into()).await?;
    }
}
// client
use rustzmq2::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut req = rustzmq2::ReqSocket::builder()
        .connect_timeout(std::time::Duration::from_secs(5))
        .build();
    req.connect("tcp://127.0.0.1:5555").await?;
    req.send("hello".into()).await?;
    let reply: String = req.recv().await?.try_into()?;
    println!("{reply}");
    Ok(())
}

See examples/ for pub/sub, security (PLAIN, CURVE, ZAP), and more.

Platforms

OS Tested in CI Notes
Linux (glibc, musl) ubuntu-latest tests (x86_64); cross-compile checks for aarch64-musl, riscv64-musl tokio and smol runtimes; TCP + IPC + inproc
macOS macos-latest tests tokio and smol runtimes; TCP + IPC + inproc
Windows windows-latest tests tokio runtime only; TCP + inproc (IPC requires Unix)
FreeBSD / NetBSD / illumos cross-compile check only no hardware test — smol build verified

Useful links

MSRV

Rust 1.85 or later.

Attribution

rustzmq2 is a fork of zeromq/zmq.rs. See CREDITS.md.

License

Licensed under either of

at your option.

The upstream zeromq/zmq.rs codebase is MIT-only; its original contributors (see CREDITS.md) retain MIT terms for their work. Contributions to this fork are dual-licensed under both MIT and Apache-2.0 unless explicitly stated otherwise.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.