A Rust library for working with posix message queues.
rust
let mq = posixmq::PosixMq::open("/queue")?;
let mut buf = vec![0; mq.attributes().max_msg_size];
loop {
let (priority, len) = mq.receive(&mut buf)?;
println!("priority: {:3}, message: {}", priority, str::from_utf8(&buf[..len])?);
}
Not all operating systems have posix message queues: Linux and most BSDs have them, but macOS, OpenBSD and Windows doesn't. See the crate documentation for details.
On Linux, FreeBSD and DragonFlyBSD posix message queues can be polled, and therefore used with mio. This feature is not enabled by default; enable it in Cargo.toml with:
toml
[dependencies]
posixmq = {version="0.1", features=["mio"]}
Also remember to open the message queues in nonblocking mode.
send()
and receive()
borrows byte slices instead of consuming and producing vectors, which avoids unnecessary allocations.mio
so the message queues can be polled.The minimum supported Rust version is 1.31.
While the crate might currently compile on older versions, a minor release can break this.
Until rustup has builds for DragonFlyBSD and Illumos, this crate will never require a newer Rust version than what is available in the DragonFlyBSD or Joyent repositories.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.