Crates.io | libzmq |
lib.rs | libzmq |
version | 0.2.5 |
source | src |
created_at | 2019-05-24 22:40:30.484388 |
updated_at | 2020-05-09 20:32:09.858403 |
description | A strict subset of ØMQ with a high level API. |
homepage | https://jean-airoldie.github.io/libzmq-rs/ |
repository | https://github.com/jean-airoldie/libzmq-rs |
max_upload_size | |
id | 136815 |
size | 377,198 |
libzmq-rs
A strict subset of ØMQ with an ergonomic API.
[dependencies]
libzmq = "0.2"
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)?;
This crate builds and generates bindings from source. This means that you
do not need to install libzmq
. However building from source requires:
API guidelines
.libzmq
)To do so we will only use a subset of libzmq
. If you'd rather have a complete
port, check out rust-zmq
.
See the FAQ
.
This project is licensed under either of
at your option.
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.