/libzmq-rs

A strict subset of ØMQ with an ergonomic API.

Primary LanguageRustApache License 2.0Apache-2.0

Apache 2.0 licensed MIT licensed

libzmq-rs

A strict subset of ØMQ with an ergonomic API.

Versioning & Stability Guarantees

Expect breaking changes with each release until 0.2. After that breaking change only on minor version until 1.0. Furthermore, since a large part of the library relies on ØMQ's DRAFT API, they will have to be stabilized before the 1.0 version is released.

[dependencies]
libzmq = "0.1.9"

Dead Simple Sample

use libzmq::{prelude::*, *};
use std::convert::TryInto;

// Use a system assigned port.
let addr: TcpAddr = "127.0.0.1:*".try_into()?;

let server = ServerBuilder::new()
    .bind(addr)
    .build()?;

// Retrieve the addr that was assigned.
let bound = server.last_endpoint()?;

let client = ClientBuilder::new()
    .connect(bound)
    .build()?;

// Send a string request.
client.send("tell me something")?;

// Receive the client request.
let msg = server.recv_msg()?;
let id = msg.routing_id().unwrap();

// Reply to the client.
let mut reply: Msg = "it takes 224 bits to store a i32 in java".into();
reply.set_routing_id(id);
server.send(reply)?;

// We can reply twice if we want.
let mut reply: Msg = "also don't talk to me".into();
reply.set_routing_id(id);
server.send(reply)?;

// Retreive the first reply.
let mut msg = client.recv_msg()?;
// And the second.
client.recv(&mut msg)?;

Installation

This crate builds and generates bindings from source. This means that you do not need to install libzmq. However building from source requires:

General Goals

  • Conform to these API guidelines.
  • Provide an ergonomic API
  • Prevent footguns (which are plentifull in libzmq)
  • Minimize the learning curve
  • Don't sacrifice any performance
  • Extensively document

To do so we will only use a subset of libzmq. If you'd rather have a complete port, check out rust-zmq.

Frequently Asked Questions

See the FAQ.

Aknowledgements

License

This project is licensed under either of

at your option.

Contribution

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