libzmq

Crates.iolibzmq
lib.rslibzmq
version0.2.5
sourcesrc
created_at2019-05-24 22:40:30.484388
updated_at2020-05-09 20:32:09.858403
descriptionA strict subset of ØMQ with a high level API.
homepagehttps://jean-airoldie.github.io/libzmq-rs/
repositoryhttps://github.com/jean-airoldie/libzmq-rs
max_upload_size
id136815
size377,198
(jean-airoldie)

documentation

README

Apache 2.0 licensed MIT licensed

libzmq-rs

A strict subset of ØMQ with an ergonomic API.

[dependencies]
libzmq = "0.2"

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.
server.route("it takes 224 bits to store a i32 in java", id)?;

// We can reply as much as we want.
server.route("also don't talk to me", id)?;

// 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.

Acknowledgements

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.

Commit count: 285

cargo fmt