Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.a
/target/
Cargo.lock
/msrv-test/target/
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: rust
rust:
- 1.32.0 # uniform paths
- stable
- beta
- nightly
Expand Down Expand Up @@ -42,6 +41,10 @@ matrix:
- cargo clean
- cargo test --all --all-features
- cargo test --all --release --all-features
- name: "MSRV (1.32.0) compile check"
rust: 1.32.0 # uniform paths
script:
- cd msrv-test && cargo build
- stage: lint
name: "Rust: rustfmt"
rust: stable
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ draft API features, have a look at
The current 0.9 release series requires `libzmq` 4.1 or newer. New
release series of `zmq` may require newer `libzmq` versions.

Regarding the minimum Rust version required, `zmq` is CI-tested on
current stable, beta and nightly channels of Rust. Additionally, it is
made sure that the code still compiles on Rust 1.32.0. However, no
tests are run for that build, so use `zmq` on older Rust versions on
your own risk. It is however likely that it will just work anyways.

# Installation

rust-zmq is available from [crates.io](https://crates.io). Users
Expand Down Expand Up @@ -123,7 +129,7 @@ need set `LIBZMQ_PREFIX` as described above.
fn main() {
let ctx = zmq::Context::new();

let mut socket = ctx.socket(zmq::REQ).unwrap();
let socket = ctx.socket(zmq::REQ).unwrap();
socket.connect("tcp://127.0.0.1:1234").unwrap();
socket.send("hello world!", 0).unwrap();
}
Expand Down
3 changes: 1 addition & 2 deletions examples/zguide/mtrelay/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ fn main() {
receiver
.bind("inproc://step3")
.expect("failed binding step 3");
let ctx = context.clone();
thread::spawn(move || step2(&ctx));
thread::spawn(move || step2(&context));
//wait for signal and pass it on
receiver.recv_msg(0).unwrap();
println!("Test successful!");
Expand Down
8 changes: 8 additions & 0 deletions msrv-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "msrv-test"
version = "0.0.1"
authors = ["Andreas Rottmann <[email protected]>"]
edition = "2018"

[dependencies]
zmq = { path = ".." }
7 changes: 7 additions & 0 deletions msrv-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
let ctx = zmq::Context::new();

let socket = ctx.socket(zmq::REQ).unwrap();
socket.connect("tcp://127.0.0.1:1234").unwrap();
socket.send("hello world!", 0).unwrap();
}
13 changes: 9 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,8 @@ unsafe impl Send for Socket {}

impl Drop for Socket {
fn drop(&mut self) {
if self.owned {
if unsafe { zmq_sys::zmq_close(self.sock) } == -1 {
panic!(errno_to_error());
}
if self.owned && unsafe { zmq_sys::zmq_close(self.sock) } == -1 {
panic!(errno_to_error());
}
}
}
Expand Down Expand Up @@ -591,6 +589,13 @@ impl Socket {
///
/// The Socket assumes ownership of the pointer and will close the socket
/// when it is dropped. The returned socket will not reference any context.
///
/// # Safety
///
/// The socket pointer must be a socket created via the `into_raw`
/// method. The ownership of the socket is transferred the returned Socket,
/// so any other pointers to the same socket may only be used until it is
/// dropped.
pub unsafe fn from_raw(sock: *mut c_void) -> Socket {
Socket {
sock,
Expand Down
8 changes: 8 additions & 0 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ impl Message {
/// function, its use is not recommended, and it will be removed in a future
/// release. If there is a use-case that cannot be handled efficiently by
/// the safe message constructors, please file an issue.
///
/// # Safety
///
/// The returned message contains uninitialized memory, and hence the
/// `Deref` and `DerefMut` traits must not be used until the memory has been
/// initialized. Since there is no proper API to do so, this function is
/// basically not usable safely, unless you happen to invoke C code that
/// takes a raw message pointer and initializes its contents.
#[deprecated(
since = "0.9.1",
note = "This method has an unintuitive name, and should not be needed."
Expand Down
7 changes: 3 additions & 4 deletions tests/compile-tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::env::var;
use std::env;
use std::path::PathBuf;

fn run_mode(mode: &'static str) {
Expand All @@ -11,9 +11,8 @@ fn run_mode(mode: &'static str) {
profile = env!("BUILD_PROFILE")
));

if let Ok(name) = var::<&str>("TESTNAME") {
let s: String = name.to_owned();
config.filter = Some(s)
if let Ok(name) = env::var("TESTNAME") {
config.filter = Some(name)
}
config.mode = cfg_mode;
config.src_base = PathBuf::from(format!("tests/{}", mode));
Expand Down