项目作者: jean-airoldie

项目描述 :
A strict subset of ØMQ with an ergonomic API.
高级语言: Rust
项目地址: git://github.com/jean-airoldie/libzmq-rs.git
创建时间: 2019-04-03T00:47:13Z
项目社区:https://github.com/jean-airoldie/libzmq-rs

开源协议:Other

下载


:warning: 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.

  1. [dependencies]
  2. libzmq = "0.2"

Dead Simple Sample

  1. use libzmq::{prelude::*, *};
  2. use std::convert::TryInto;
  3. // Use a system assigned port.
  4. let addr: TcpAddr = "127.0.0.1:*".try_into()?;
  5. let server = ServerBuilder::new()
  6. .bind(addr)
  7. .build()?;
  8. // Retrieve the addr that was assigned.
  9. let bound = server.last_endpoint()?;
  10. let client = ClientBuilder::new()
  11. .connect(bound)
  12. .build()?;
  13. // Send a string request.
  14. client.send("tell me something")?;
  15. // Receive the client request.
  16. let msg = server.recv_msg()?;
  17. let id = msg.routing_id().unwrap();
  18. // Reply to the client.
  19. server.route("it takes 224 bits to store a i32 in java", id)?;
  20. // We can reply as much as we want.
  21. server.route("also don't talk to me", id)?;
  22. // Retreive the first reply.
  23. let mut msg = client.recv_msg()?;
  24. // And the second.
  25. 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.