arzmq

Crates.ioarzmq
lib.rsarzmq
version0.5.7
created_at2025-07-23 20:11:03.011487+00
updated_at2025-11-02 12:04:10.115102+00
descriptionHigh-level bindings to the zeromq library
homepage
repositoryhttps://github.com/mgaertne/arzmq
max_upload_size
id1765223
size762,335
Markus Gärtner (mgaertne)

documentation

https://docs.rs/arzmq

README

Asynchronous Rust bindings for 0MQ (arzmq)

Apache 2.0 licensed MIT licensed Crates.io Version docs.rs

Documentation

About

The arzmq crate provides bindings for the libzmq library from the ZeroMQ project. The API exposed by arzmq should be safe (in the usual Rust sense), but it follows the C API closely, so it is not very idiomatic.

There are feature flags for enabling a builder interface for contexts and sockets as well as a feature flag for enabling 0MQ's draft-api available.

Compatibility

The aim of this project is to track latest zmq releases as close as possible.

Usage

arzmq is a pretty straight forward port of the C API into Rust:

use std::thread;

use arzmq::prelude::{Context, RequestSocket, ReplySocket, SendFlags, Receiver, RecvFlags, Sender};

fn run_reply(context: &Context, endpoint: &str) {
    let socket = ReplySocket::from_context(context).unwrap();
    socket.bind(endpoint).unwrap();
    
    thread::spawn(move || {
       while socket.recv_msg(RecvFlags::DONT_WAIT).is_err() {}
    });
}

fn main() {
    let ctx = Context::new().unwrap();
    
    run_reply(&ctx, "tcp://127.0.0.1:1234");

    let socket = RequestSocket::from_context(&ctx).unwrap();
    socket.connect("tcp://127.0.0.1:1234").unwrap();
    let _ = socket.send_msg("hello world!", SendFlags::DONT_WAIT);
}

You can find more usage examples in https://github.com/mgaertne/arzmq/tree/master/examples.

Commit count: 0

cargo fmt