Skip to content
This repository has been archived by the owner on Nov 28, 2020. It is now read-only.
/ libzmq-rs Public archive

A strict subset of ØMQ with an ergonomic API.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

jean-airoldie/libzmq-rs

Repository files navigation

⚠️ I wouldn't recommand using ZeroMQ or any ZeroMq bindings library (including libzmq-rs), unless you absolutely have to. If you do, then libzmq-rs might fit your use case since it basically makes ZeroMQ not a complete footgun. However, just because this library hides the unmaintainable mess that is ZeroMQ, doesn't mean the mess does not exist. See this comment for more context.

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.

About

A strict subset of ØMQ with an ergonomic API.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages