From 0b146dc0792dd51cf8b343a1e9114b06242e9d14 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 20 Jan 2020 11:48:35 +0000 Subject: [PATCH] chore(ops/posix_mq.rs): Update crate dependencies to recent versions First bump since 2017! This changes the code to be compatible with newer versions of the `nix` crate, which has shuffled things around a bit. --- ops/posix_mq.rs/Cargo.toml | 8 ++++---- ops/posix_mq.rs/LICENSE | 2 +- ops/posix_mq.rs/src/error.rs | 6 +++--- ops/posix_mq.rs/src/lib.rs | 26 +++++++++----------------- ops/posix_mq.rs/src/tests.rs | 2 +- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/ops/posix_mq.rs/Cargo.toml b/ops/posix_mq.rs/Cargo.toml index db471168c..d72e87a3d 100644 --- a/ops/posix_mq.rs/Cargo.toml +++ b/ops/posix_mq.rs/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "posix_mq" -version = "0.1.3" -authors = ["Vincent Ambo "] +version = "0.9.0" +authors = ["Vincent Ambo "] description = "(Higher-level) Rust bindings to POSIX message queues" license = "MIT" -repository = "https://github.com/aprilabank/posix_mq.rs" +repository = "https://git.tazj.in/tree/ops/posix_mq.rs" [dependencies] -nix = "0.9" +nix = "0.16" libc = "0.2" diff --git a/ops/posix_mq.rs/LICENSE b/ops/posix_mq.rs/LICENSE index b1b8e03c8..2389546b1 100644 --- a/ops/posix_mq.rs/LICENSE +++ b/ops/posix_mq.rs/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Vincent Ambo +Copyright (c) 2017-2020 Vincent Ambo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ops/posix_mq.rs/src/error.rs b/ops/posix_mq.rs/src/error.rs index 1a0c069a8..1ef585c01 100644 --- a/ops/posix_mq.rs/src/error.rs +++ b/ops/posix_mq.rs/src/error.rs @@ -43,7 +43,7 @@ pub enum Error { // If an unhandled / unknown / unexpected error occurs this error will be used. // In those cases bug reports would be welcome! - UnknownForeignError(nix::Errno), + UnknownForeignError(nix::errno::Errno), // Some other unexpected / unknown error occured. This is probably an error from // the nix crate. Bug reports also welcome for this! @@ -112,8 +112,8 @@ impl From for Error { } -fn match_errno(err: nix::Errno) -> Error { - use nix::errno::*; +fn match_errno(err: nix::errno::Errno) -> Error { + use nix::errno::Errno::*; match err { EACCES => Error::PermissionDenied(), diff --git a/ops/posix_mq.rs/src/lib.rs b/ops/posix_mq.rs/src/lib.rs index b8f2fed10..057601ecc 100644 --- a/ops/posix_mq.rs/src/lib.rs +++ b/ops/posix_mq.rs/src/lib.rs @@ -16,14 +16,6 @@ pub mod error; #[cfg(test)] mod tests; -/* -TODO: - -* what happens if permissions change after FD was opened? -* drop dependency on nix crate? - -*/ - /// Wrapper type for queue names that performs basic validation of queue names before calling /// out to C code. #[derive(Debug, Clone, PartialEq)] @@ -97,11 +89,11 @@ impl Queue { let oflags = { let mut flags = mqueue::MQ_OFlag::empty(); // Put queue in r/w mode - flags.toggle(mqueue::O_RDWR); + flags.toggle(mqueue::MQ_OFlag::O_RDWR); // Enable queue creation - flags.toggle(mqueue::O_CREAT); + flags.toggle(mqueue::MQ_OFlag::O_CREAT); // Fail if queue exists already - flags.toggle(mqueue::O_EXCL); + flags.toggle(mqueue::MQ_OFlag::O_EXCL); flags }; @@ -128,7 +120,7 @@ impl Queue { pub fn open(name: Name) -> Result { // No extra flags need to be constructed as the default is to open and fail if the // queue does not exist yet - which is what we want here. - let oflags = mqueue::O_RDWR; + let oflags = mqueue::MQ_OFlag::O_RDWR; let queue_descriptor = mqueue::mq_open( &name.0, oflags, @@ -151,9 +143,9 @@ impl Queue { let oflags = { let mut flags = mqueue::MQ_OFlag::empty(); // Put queue in r/w mode - flags.toggle(mqueue::O_RDWR); + flags.toggle(mqueue::MQ_OFlag::O_RDWR); // Enable queue creation - flags.toggle(mqueue::O_CREAT); + flags.toggle(mqueue::MQ_OFlag::O_CREAT); flags }; @@ -239,8 +231,8 @@ impl Drop for Queue { // Creates the default queue mode (0600). fn default_mode() -> stat::Mode { let mut mode = stat::Mode::empty(); - mode.toggle(stat::S_IRUSR); - mode.toggle(stat::S_IWUSR); + mode.toggle(stat::Mode::S_IRUSR); + mode.toggle(stat::Mode::S_IWUSR); mode } @@ -271,7 +263,7 @@ fn mq_getattr(mqd: mqd_t) -> Result { use std::mem; let mut attr = unsafe { mem::uninitialized::() }; let res = unsafe { libc::mq_getattr(mqd, &mut attr) }; - nix::Errno::result(res) + nix::errno::Errno::result(res) .map(|_| attr) .map_err(|e| e.into()) } diff --git a/ops/posix_mq.rs/src/tests.rs b/ops/posix_mq.rs/src/tests.rs index 0018e40da..7a08876ae 100644 --- a/ops/posix_mq.rs/src/tests.rs +++ b/ops/posix_mq.rs/src/tests.rs @@ -18,5 +18,5 @@ fn test_open_delete() { assert_eq!(message, result); - queue.delete(); + queue.delete().expect("deleting queue failed"); }