From f72608375936814d898360fc7c392e385bc19d40 Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 8 Jul 2021 14:13:59 +0200 Subject: [PATCH 01/11] Remove unneccessary `pub` declarations --- src/posix/info.rs | 2 +- src/posix/recv.rs | 12 ++++++------ src/posix/send.rs | 12 ++++++------ src/sysv/unlink.rs | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/posix/info.rs b/src/posix/info.rs index 0fd1e76..abf9641 100644 --- a/src/posix/info.rs +++ b/src/posix/info.rs @@ -7,7 +7,7 @@ use posixmq::PosixMq; pub struct Info { /// Name of the queue #[clap(value_name = "QUEUE")] - pub queue: String, + queue: String, } impl Info { diff --git a/src/posix/recv.rs b/src/posix/recv.rs index 0b8563a..6d83cef 100644 --- a/src/posix/recv.rs +++ b/src/posix/recv.rs @@ -11,22 +11,22 @@ use std::str; pub struct Recv { /// Do not block #[clap(short, long)] - pub non_blocking: bool, + non_blocking: bool, /// Print messages as they are received #[clap(short, long)] - pub follow: bool, + follow: bool, /// Print a timestamp before each message #[clap(short, long)] - pub timestamp: bool, + timestamp: bool, /// Timeout, example "5h 23min 42ms" #[clap(short = 'o', long, conflicts_with = "deadline")] - pub timeout: Option, + timeout: Option, /// Deadline until messages are received (format: "%Y-%m-%d %H:%M:%S") #[clap(short, long, conflicts_with = "timeout")] - pub deadline: Option, + deadline: Option, /// Name of the queue #[clap(value_name = "QUEUE")] - pub queue: String, + queue: String, } fn print_message(priority: u32, length: usize, timestamp: bool, msg: &str) { diff --git a/src/posix/send.rs b/src/posix/send.rs index 917679b..d6feefc 100644 --- a/src/posix/send.rs +++ b/src/posix/send.rs @@ -9,22 +9,22 @@ use log::info; pub struct Send { /// Set a different priority, priority >= 0 #[clap(short, long, default_value = "0")] - pub priority: u32, + priority: u32, /// Do not block #[clap(short, long)] - pub non_blocking: bool, + non_blocking: bool, /// Timeout, example "5h 23min 42ms" #[clap(short = 'o', long, conflicts_with = "deadline")] - pub timeout: Option, + timeout: Option, /// Deadline until messages are sent (format: "%Y-%m-%d %H:%M:%S") #[clap(short, long, conflicts_with = "timeout")] - pub deadline: Option, + deadline: Option, /// Name of the queue #[clap(value_name = "QUEUE")] - pub queue: String, + queue: String, /// Message to be sent to the queue #[clap(value_name = "MESSAGE")] - pub msg: String, + msg: String, } impl Send { diff --git a/src/sysv/unlink.rs b/src/sysv/unlink.rs index 277edb6..ede5b67 100644 --- a/src/sysv/unlink.rs +++ b/src/sysv/unlink.rs @@ -12,10 +12,10 @@ pub struct Unlink { required_unless_present_any = &["key"], conflicts_with = "key" )] - pub id: Option, + id: Option, /// Key of the queue #[clap(long, short, required_unless_present_any = &["id"], conflicts_with = "id")] - pub key: Option, + key: Option, } impl Unlink { From 8d127d840ef29ea718562de16c55c99776be6cde Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 8 Jul 2021 14:14:25 +0200 Subject: [PATCH 02/11] Minor fixes in readme and clap help --- README.md | 7 ++++--- src/posix/list.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e7251f7..12bbbff 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # mqrs -`mqrs` is a small cli application to handle POSIX message queues. +`mqrs` is a small cli application to handle different kinds of message +queues. ## Install `mqrs` For information about how to build, install and run `mqrs` please see @@ -8,8 +9,8 @@ For information about how to build, install and run `mqrs` please see ## Using `mqrs` Depending on which backend you want to use there are different subsets of subcommands. Following backends are supported: -- `posix`: Uses POSIX message queues -- `sysv`: Uses SysV IPC message queues +- `posix`: Use POSIX message queues +- `sysv`: Use SysV IPC message queues If a command is clearly distinguishable from all the others, it does not have to be completed further. diff --git a/src/posix/list.rs b/src/posix/list.rs index 54c031a..f9c02b6 100644 --- a/src/posix/list.rs +++ b/src/posix/list.rs @@ -4,7 +4,7 @@ use clap::Clap; use log::warn; use std::{fs, os::unix::fs::PermissionsExt}; -/// Print information about an existing message queue +/// Print a list of existing message queues #[derive(Clap, Debug)] pub struct List { /// Show all parameters From f4796e7da65ad00053c9b4baacd2fbd40526030c Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 8 Jul 2021 14:20:53 +0200 Subject: [PATCH 03/11] Refactor `sysvmq::unlink_*` and check for error Use `sysvmq::id_from_key(key)` to receive the id of a queue identified with `key`. Here an error check is added as well. Adapt `Sysv::Unlink::run()` to comply with that change. --- src/sysv/unlink.rs | 6 ++++-- sysvmq/src/lib.rs | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sysv/unlink.rs b/src/sysv/unlink.rs index ede5b67..981289b 100644 --- a/src/sysv/unlink.rs +++ b/src/sysv/unlink.rs @@ -25,9 +25,11 @@ impl Unlink { info!("Removed message queue with id: {}", id); } else if let Some(key) = self.key { - sysvmq::unlink_key(key)?; + let id = sysvmq::id_from_key(key)?; - info!("Removed message queue key: {}", key); + sysvmq::unlink_id(id)?; + + info!("Removed message queue key: {} (id: {})", key, id); } Ok(()) diff --git a/sysvmq/src/lib.rs b/sysvmq/src/lib.rs index bb2c21d..b9de136 100644 --- a/sysvmq/src/lib.rs +++ b/sysvmq/src/lib.rs @@ -69,10 +69,13 @@ pub fn unlink_id(id: i32) -> Result<(), SysvMqError> { } } -pub fn unlink_key(key: i32) -> Result<(), SysvMqError> { +pub fn id_from_key(key: i32) -> Result { let id = unsafe { msgget(key, 0) }; - unlink_id(id) + match id { + -1 => Err(SysvMqError::ErrnoError(Errno::from_i32(errno()).desc())), + id => Ok(id), + } } pub struct SysvMq { From 4c82d41f8e198a0a9aac83527e2734f384238044 Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 8 Jul 2021 14:46:10 +0200 Subject: [PATCH 04/11] Implement printing a list of SysV IPC mqs What could be improved is when printing the information to use a better human readable format. As usual the readme and the man page are both updated. --- README.md | 4 ++++ mqrs.1 | 12 ++++++++++++ src/main.rs | 2 ++ src/sysv.rs | 2 ++ src/sysv/list.rs | 26 ++++++++++++++++++++++++++ 5 files changed, 46 insertions(+) create mode 100644 src/sysv/list.rs diff --git a/README.md b/README.md index 12bbbff..5f68f7c 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ queue. Following optional arguments are supported: - `-m`, `--mode`: Permissions (octal) to create the queue with. Default: 0644. +#### List all message queues +Use the `list` command to print a list of all message queues. No +further arguments are supported. + #### Delete a message queue Use the `unlink` command to delete a message queue. This can either be done by providing a `key` or an `id` of the queue: diff --git a/mqrs.1 b/mqrs.1 index eb7b912..af46d24 100644 --- a/mqrs.1 +++ b/mqrs.1 @@ -241,6 +241,18 @@ Produce verbose output .B \-m, \-\-mode \fI\fP Permissions (octal) to create the queue with (default: 0644) .RE +.SS list [FLAGS] +Print a list of all existing SysV IPC message queues. +.TP 8 +.SS FLAGS +.RS +.TP 8 +.B \-h, \-\-help +Prints help information +.TP 8 +.B \-v, \-\-verbose +Produce verbose output +.RE .SS unlink [FLAGS] [OPTIONS] Delete an existing SysV IPC message queue. It is mandatory to pass exactly one OPTION. diff --git a/src/main.rs b/src/main.rs index 5e4db83..854ae95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,7 @@ enum PosixCommand { #[derive(Clap, Debug)] enum SysvCommand { Create(sysv::Create), + List(sysv::List), Unlink(sysv::Unlink), } @@ -69,6 +70,7 @@ fn main() -> Result<()> { }, Backend::Sysv(s) => match s { SysvCommand::Create(c) => c.run()?, + SysvCommand::List(l) => l.run()?, SysvCommand::Unlink(u) => u.run()?, }, } diff --git a/src/sysv.rs b/src/sysv.rs index 91ee1a5..05edc1e 100644 --- a/src/sysv.rs +++ b/src/sysv.rs @@ -1,5 +1,7 @@ mod create; +mod list; mod unlink; pub use create::Create; +pub use list::List; pub use unlink::Unlink; diff --git a/src/sysv/list.rs b/src/sysv/list.rs new file mode 100644 index 0000000..f7e6ff7 --- /dev/null +++ b/src/sysv/list.rs @@ -0,0 +1,26 @@ +use anyhow::Result; +use clap::Clap; +use std::{ + fs::File, + io::{BufRead, BufReader}, +}; + +/// Print a list of existing message queues +#[derive(Clap, Debug)] +pub struct List {} + +impl List { + pub fn run(&self) -> Result<()> { + let file = BufReader::new(File::open("/proc/sysvipc/msg")?); + + for line in file.lines() { + for field in line?.split_whitespace().collect::>() { + print!("{0: <10}", field); + } + + println!(); + } + + Ok(()) + } +} From 9666e0788df1be34813787edfeaa284f29080e19 Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 8 Jul 2021 17:44:46 +0200 Subject: [PATCH 05/11] Implement `info` command for SysV IPC mqs The `list` command was refactored a little bit as well and the man page and readme were updated. --- README.md | 6 +++++ mqrs.1 | 58 +++++++++++++++++++++++++++++++++++++--------- src/main.rs | 2 ++ src/sysv.rs | 2 ++ src/sysv/info.rs | 53 ++++++++++++++++++++++++++++++++++++++++++ src/sysv/list.rs | 4 +--- src/sysv/unlink.rs | 4 ++-- 7 files changed, 113 insertions(+), 16 deletions(-) create mode 100644 src/sysv/info.rs diff --git a/README.md b/README.md index 5f68f7c..9e73663 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,12 @@ queue. Following optional arguments are supported: - `-m`, `--mode`: Permissions (octal) to create the queue with. Default: 0644. +#### Print information about a message queue +Use the `info` command to print further information about a message +queue. Exactly of the following arguments is mandatory: +- `-i`, `--id id`: Id of the queue +- `-k`, `--key key`: Key of the queue + #### List all message queues Use the `list` command to print a list of all message queues. No further arguments are supported. diff --git a/mqrs.1 b/mqrs.1 index af46d24..45116a5 100644 --- a/mqrs.1 +++ b/mqrs.1 @@ -41,7 +41,7 @@ The POSIX backend supports six commands: and .B recv . -.SS create [FLAGS] [OPTIONS] \fI\fP +.SS posix create [FLAGS] [OPTIONS] \fI\fP Create a new POSIX message queue. .TP 8 .SS ARGS @@ -72,7 +72,7 @@ Message size in bytes .B \-m, \-\-mode \fI\fP Permissions (octal) to create the queue with .RE -.SS help [SUBCOMMAND] +.SS posix help [SUBCOMMAND] Prints this message or the help of the given subcommand. .TP 8 .SS ARGS @@ -81,7 +81,7 @@ Prints this message or the help of the given subcommand. .B \fI\fP Show help for \fISUBCOMMAND\fP .RE -.SS info [FLAGS] \fI\fP +.SS posix info [FLAGS] \fI\fP Print further information about an existing message queue. .TP 8 .SS ARGS @@ -100,7 +100,7 @@ Prints help information .B \-v, \-\-verbose Produce verbose output .RE -.SS list [FLAGS] +.SS posix list [FLAGS] Print a list of all existing POSIX message queues. .TP 8 .SS FLAGS @@ -115,7 +115,7 @@ Produce verbose output .B \-a, \-\-all Print all available information .RE -.SS recv [FLAGS] [OPTIONS] \fI\fP +.SS posix recv [FLAGS] [OPTIONS] \fI\fP Receive and print one or more messages message from a message queue. .TP 8 .SS ARGS @@ -153,7 +153,7 @@ Deadline until messages are received (format: "%Y-%m-%d %H:%M:%S") .B \-o, \-\-timeout \fI\fP Timeout as for example in "5h 23min 42ms" .RE -.SS send [FLAGS] [OPTIONS] \fI\fP \fI\fP +.SS posix send [FLAGS] [OPTIONS] \fI\fP \fI\fP Send a message to a message queue. .TP 8 .SS ARGS @@ -191,7 +191,7 @@ Set a different priority than default, priority >= 0 [default: 0] .B \-o, \-\-timeout \fI\fP Timeout as for example in "5h 23min 42ms" .RE -.SS unlink [FLAGS] \fI\fP +.SS posix unlink [FLAGS] \fI\fP Delete an existing POSIX message queue. .TP 8 .SS ARGS @@ -211,12 +211,16 @@ Prints help information Produce verbose output .RE .SH SYSV IPC MESSAGE QUEUE SUBCOMMANDS -The SysV IPC backend supports two commands: +The SysV IPC backend supports four commands: .B create\ +, +.B info\ +, +.B list and .B unlink\ . -.SS create [FLAGS] [OPTIONS] \fI\fP +.SS sysv create [FLAGS] [OPTIONS] \fI\fP Create a new SysV IPC message queue. .TP 8 .SS ARGS @@ -241,7 +245,39 @@ Produce verbose output .B \-m, \-\-mode \fI\fP Permissions (octal) to create the queue with (default: 0644) .RE -.SS list [FLAGS] +.SS sysv help [SUBCOMMAND] +Prints this message or the help of the given subcommand. +.TP 8 +.SS ARGS +.RS +.TP 8 +.B \fI\fP +Show help for \fISUBCOMMAND\fP +.RE +.SS sysv info [FLAGS] [OPTIONS] +Print further information about an existing message queue. Exactly of +the OPTION arguments is mandatory. +.TP 8 +.SS FLAGS +.RS +.TP 8 +.B \-h, \-\-help +Prints help information +.TP 8 +.B \-v, \-\-verbose +Produce verbose output +.RE +.TP 8 +.SS OPTIONS +.RS +.TP 8 +.B \-i, \-\-id \fI\fP +Id of the queue +.TP 8 +.B \-k, \-\-key \fI\fP +Key of the queue +.RE +.SS sysv list [FLAGS] Print a list of all existing SysV IPC message queues. .TP 8 .SS FLAGS @@ -253,7 +289,7 @@ Prints help information .B \-v, \-\-verbose Produce verbose output .RE -.SS unlink [FLAGS] [OPTIONS] +.SS sysv unlink [FLAGS] [OPTIONS] Delete an existing SysV IPC message queue. It is mandatory to pass exactly one OPTION. .TP 8 diff --git a/src/main.rs b/src/main.rs index 854ae95..b2dc94b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,7 @@ enum PosixCommand { #[derive(Clap, Debug)] enum SysvCommand { Create(sysv::Create), + Info(sysv::Info), List(sysv::List), Unlink(sysv::Unlink), } @@ -70,6 +71,7 @@ fn main() -> Result<()> { }, Backend::Sysv(s) => match s { SysvCommand::Create(c) => c.run()?, + SysvCommand::Info(i) => i.run()?, SysvCommand::List(l) => l.run()?, SysvCommand::Unlink(u) => u.run()?, }, diff --git a/src/sysv.rs b/src/sysv.rs index 05edc1e..7270e78 100644 --- a/src/sysv.rs +++ b/src/sysv.rs @@ -1,7 +1,9 @@ mod create; +mod info; mod list; mod unlink; pub use create::Create; +pub use info::Info; pub use list::List; pub use unlink::Unlink; diff --git a/src/sysv/info.rs b/src/sysv/info.rs new file mode 100644 index 0000000..42d9fac --- /dev/null +++ b/src/sysv/info.rs @@ -0,0 +1,53 @@ +use anyhow::Result; +use clap::Clap; +use std::{ + fs::File, + io::{BufRead, BufReader}, +}; + +/// Print information about an existing message queue +#[derive(Clap, Debug)] +pub struct Info { + /// Id of the queue + #[clap(short, long, required_unless_present_any = &["key"], conflicts_with = "key")] + id: Option, + /// Key of the queue + #[clap(short, long, required_unless_present_any = &["id"], conflicts_with = "id")] + key: Option, +} + +fn print_line(line: &str) { + for field in line.split_whitespace().collect::>() { + print!("{0: <10}", field); + } + + println!(); +} + +impl Info { + pub fn run(&self) -> Result<()> { + let mut lines = BufReader::new(File::open("/proc/sysvipc/msg")?).lines(); + + print_line(&lines.nth(0).unwrap_or(Ok(String::new()))?); + + for line in lines { + let line = line?; + + if let Some(id) = self.id { + if id == line.split_whitespace().collect::>()[1].parse::()? { + print_line(&line); + + break; + } + } else if let Some(key) = self.key { + if key == line.split_whitespace().collect::>()[0].parse::()? { + print_line(&line); + + break; + } + } + } + + Ok(()) + } +} diff --git a/src/sysv/list.rs b/src/sysv/list.rs index f7e6ff7..9f66951 100644 --- a/src/sysv/list.rs +++ b/src/sysv/list.rs @@ -11,9 +11,7 @@ pub struct List {} impl List { pub fn run(&self) -> Result<()> { - let file = BufReader::new(File::open("/proc/sysvipc/msg")?); - - for line in file.lines() { + for line in BufReader::new(File::open("/proc/sysvipc/msg")?).lines() { for field in line?.split_whitespace().collect::>() { print!("{0: <10}", field); } diff --git a/src/sysv/unlink.rs b/src/sysv/unlink.rs index 981289b..8723d20 100644 --- a/src/sysv/unlink.rs +++ b/src/sysv/unlink.rs @@ -7,14 +7,14 @@ use log::info; pub struct Unlink { /// Id of the queue #[clap( - long, short, + long, required_unless_present_any = &["key"], conflicts_with = "key" )] id: Option, /// Key of the queue - #[clap(long, short, required_unless_present_any = &["id"], conflicts_with = "id")] + #[clap(short, long, required_unless_present_any = &["id"], conflicts_with = "id")] key: Option, } From ecd5ee5a36f9d1b5e0ded62bde3952dff52c157a Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 9 Jul 2021 00:31:51 +0200 Subject: [PATCH 06/11] Add functions to print information about SysV mqs Not needed yet but maybe useful.. --- sysvmq/src/lib.rs | 62 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/sysvmq/src/lib.rs b/sysvmq/src/lib.rs index b9de136..298a48e 100644 --- a/sysvmq/src/lib.rs +++ b/sysvmq/src/lib.rs @@ -1,21 +1,15 @@ use libc::{ - msgctl, msgget, msqid_ds, IPC_CREAT, IPC_EXCL, IPC_INFO, IPC_NOWAIT, IPC_PRIVATE, IPC_RMID, - IPC_SET, IPC_STAT, MSG_COPY, MSG_EXCEPT, MSG_INFO, MSG_NOERROR, MSG_STAT, + msgctl, msgget, msginfo, msqid_ds, IPC_CREAT, IPC_EXCL, IPC_INFO, IPC_NOWAIT, IPC_PRIVATE, + IPC_RMID, IPC_SET, IPC_STAT, MSG_COPY, MSG_EXCEPT, MSG_INFO, MSG_NOERROR, MSG_STAT, }; use nix::errno::{errno, Errno}; -use std::{marker::PhantomData, num::ParseIntError, ptr}; +use std::{marker::PhantomData, mem::MaybeUninit, ptr}; use thiserror::Error; #[derive(Debug, Error)] pub enum SysvMqError { #[error("SysV message queue: {0}")] ErrnoError(&'static str), - #[error("No message queue found with key {0}")] - KeyNotFound(i32), - #[error("IO Error: {0}")] - IoError(#[from] std::io::Error), - #[error("Parse Error: {0}")] - ParserError(#[from] ParseIntError), } /// IPC bit flags @@ -78,6 +72,56 @@ pub fn id_from_key(key: i32) -> Result { } } +pub fn ipc_info(id: i32) -> Result<(), SysvMqError> { + let mut msginfo = MaybeUninit::::uninit(); + + unsafe { + msgctl( + id, + ControlCommands::IpcInfo as i32, + msginfo.as_mut_ptr() as *mut msqid_ds, + ); + } + + let msginfo = unsafe { msginfo.assume_init() }; + + println!("info: {:?}", msginfo); + + Ok(()) +} + +pub fn stat_info(id: i32) -> Result<(), SysvMqError> { + let mut msginfo = MaybeUninit::::uninit(); + + unsafe { + msgctl(id, ControlCommands::Stat as i32, msginfo.as_mut_ptr()); + } + + let msginfo = unsafe { msginfo.assume_init() }; + + println!("info: {:?}", msginfo); + + Ok(()) +} + +pub fn msg_info(id: i32) -> Result<(), SysvMqError> { + let mut msginfo = MaybeUninit::::uninit(); + + unsafe { + msgctl( + id, + ControlCommands::MsgInfo as i32, + msginfo.as_mut_ptr() as *mut msqid_ds, + ); + } + + let msginfo = unsafe { msginfo.assume_init() }; + + println!("info: {:?}", msginfo); + + Ok(()) +} + pub struct SysvMq { pub id: i32, pub key: i32, From 90a3a5eb524b3b98e6e760622d851864b65fbbe9 Mon Sep 17 00:00:00 2001 From: finga Date: Sun, 10 Oct 2021 01:17:48 +0200 Subject: [PATCH 07/11] Use mod files To have things more self contained. --- src/{posix.rs => posix/mod.rs} | 0 src/{sysv.rs => sysv/mod.rs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/{posix.rs => posix/mod.rs} (100%) rename src/{sysv.rs => sysv/mod.rs} (100%) diff --git a/src/posix.rs b/src/posix/mod.rs similarity index 100% rename from src/posix.rs rename to src/posix/mod.rs diff --git a/src/sysv.rs b/src/sysv/mod.rs similarity index 100% rename from src/sysv.rs rename to src/sysv/mod.rs From 8150e30ef54dcd20590662cc395f96c82db1c294 Mon Sep 17 00:00:00 2001 From: finga Date: Sun, 10 Oct 2021 01:19:00 +0200 Subject: [PATCH 08/11] Update descriptions and manpage Reflect coping with different message queues. --- Cargo.toml | 4 ++-- mqrs.1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index edbaea8..b69b952 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" repository = "https://git.onders.org/finga/mqrs" license = "GPL-3.0-or-later" readme = "README.md" -description = "A CLI program for interacting with Posix Message Queues." +description = "A CLI program for interacting with different kinds of message queues." keywords = ["message_queue", "mq", "mqueue", "queue"] categories = ["command-line-utilities"] @@ -24,7 +24,7 @@ sysvmq = { path = "sysvmq" } members = ["sysvmq"] [package.metadata.deb] -extended-description = "`mqrs` is a small cli application to handle POSIX message queues." +extended-description = "`mqrs` is a small cli application to handle different kinds of message queues." assets = [ ["target/release/mqrs", "usr/bin/", "755"], ["README.md", "usr/share/doc/cargo-deb/README.md", "644"], diff --git a/mqrs.1 b/mqrs.1 index 45116a5..ce48a87 100644 --- a/mqrs.1 +++ b/mqrs.1 @@ -319,7 +319,7 @@ Id of the queue Key of the queue .RE .SH SEE ALSO -mq_overview(7) +mq_overview(7), sysvipc(7) .SH BUGS No known bugs. .SH AUTHOR From d5ef64171a530bb7e0de96235978da56003eccc9 Mon Sep 17 00:00:00 2001 From: finga Date: Sun, 10 Oct 2021 01:23:17 +0200 Subject: [PATCH 09/11] Cargo update and fix clap changes To support the latest beta version of clap (v3.0.0-beta.4) small changes were necessary. --- Cargo.lock | 61 ++++++++++++++++++++++++++--------------------------- src/main.rs | 4 +++- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c4a517..0485090 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.41" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" +checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" [[package]] name = "atty" @@ -42,9 +42,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cc" -version = "1.0.68" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" [[package]] name = "cfg-if" @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.0-beta.2" +version = "3.0.0-beta.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142" +checksum = "fcd70aa5597dbc42f7217a543f9ef2768b2ef823ba29036072d30e1d88e98406" dependencies = [ "atty", "bitflags", @@ -80,15 +80,14 @@ dependencies = [ "strsim", "termcolor", "textwrap", - "unicode-width", "vec_map", ] [[package]] name = "clap_derive" -version = "3.0.0-beta.2" +version = "3.0.0-beta.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1" +checksum = "0b5bb0d655624a0b8770d1c178fb8ffcb1f91cc722cb08f451e3dc72465421ac" dependencies = [ "heck", "proc-macro-error", @@ -158,9 +157,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" [[package]] name = "log" @@ -173,9 +172,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" @@ -202,9 +201,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c3728fec49d363a50a8828a190b379a446cc5cf085c06259bbbeb34447e4ec7" +checksum = "77d9f3521ea8e0641a153b3cddaf008dcbf26acd4ed739a2517295e0760d12c7" dependencies = [ "bitflags", "cc", @@ -234,9 +233,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "2.4.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85" +checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d" [[package]] name = "posixmq" @@ -273,18 +272,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -314,9 +313,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.73" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" dependencies = [ "proc-macro2", "quote", @@ -343,27 +342,27 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.12.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789" +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" dependencies = [ "unicode-width", ] [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -389,9 +388,9 @@ checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" diff --git a/src/main.rs b/src/main.rs index b2dc94b..2e01aa6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,8 +7,10 @@ mod sysv; #[derive(Clap, Debug)] enum Backend { /// Handle POSIX message queues + #[clap(subcommand)] Posix(PosixCommand), /// Handle SysV message queues + #[clap(subcommand)] Sysv(SysvCommand), } @@ -35,7 +37,7 @@ enum SysvCommand { version = crate_version!(), author = crate_authors!(", "), setting = AppSettings::SubcommandRequiredElseHelp, - global_setting = AppSettings::VersionlessSubcommands, + global_setting = AppSettings::PropagateVersion, global_setting = AppSettings::InferSubcommands, )] struct Opts { From 1aab989000168db605cd0f0e23b58475a566bdc2 Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 3 Dec 2021 14:50:23 +0100 Subject: [PATCH 10/11] Update build dependencies and edition Use the 2021 Rust edition. To use current version of clap changes were adapted. --- Cargo.lock | 52 +++++++++++++++++++++++++-------------------- Cargo.toml | 2 +- src/main.rs | 10 ++++----- src/posix/create.rs | 4 ++-- src/posix/info.rs | 4 ++-- src/posix/list.rs | 4 ++-- src/posix/recv.rs | 4 ++-- src/posix/send.rs | 4 ++-- src/posix/unlink.rs | 4 ++-- src/sysv/create.rs | 4 ++-- src/sysv/info.rs | 4 ++-- src/sysv/list.rs | 4 ++-- src/sysv/unlink.rs | 4 ++-- 13 files changed, 55 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0485090..dc36e4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.44" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "atty" @@ -42,9 +42,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cc" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcd70aa5597dbc42f7217a543f9ef2768b2ef823ba29036072d30e1d88e98406" +checksum = "feff3878564edb93745d58cf63e17b63f24142506e7a20c87a5521ed7bfb1d63" dependencies = [ "atty", "bitflags", @@ -80,14 +80,14 @@ dependencies = [ "strsim", "termcolor", "textwrap", - "vec_map", + "unicase", ] [[package]] name = "clap_derive" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5bb0d655624a0b8770d1c178fb8ffcb1f91cc722cb08f451e3dc72465421ac" +checksum = "8b15c6b4f786ffb6192ffe65a36855bc1fc2444bcd0945ae16748dcd6ed7d0d3" dependencies = [ "heck", "proc-macro-error", @@ -157,9 +157,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.103" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "log" @@ -233,9 +233,12 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "3.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d" +checksum = "addaa943333a514159c80c97ff4a93306530d965d27e139188283cd13e06a799" +dependencies = [ + "memchr", +] [[package]] name = "posixmq" @@ -272,9 +275,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] @@ -313,9 +316,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" dependencies = [ "proc-macro2", "quote", @@ -380,6 +383,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-segmentation" version = "1.8.0" @@ -398,12 +410,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.3" diff --git a/Cargo.toml b/Cargo.toml index b69b952..f8005b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mqrs" version = "0.1.1" authors = ["finga "] -edition = "2018" +edition = "2021" repository = "https://git.onders.org/finga/mqrs" license = "GPL-3.0-or-later" readme = "README.md" diff --git a/src/main.rs b/src/main.rs index 2e01aa6..c4b0787 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,10 @@ use anyhow::Result; -use clap::{crate_authors, crate_version, AppSettings, Clap}; +use clap::{crate_authors, crate_version, AppSettings, Parser}; mod posix; mod sysv; -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] enum Backend { /// Handle POSIX message queues #[clap(subcommand)] @@ -14,7 +14,7 @@ enum Backend { Sysv(SysvCommand), } -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] enum PosixCommand { Create(posix::Create), Info(posix::Info), @@ -24,7 +24,7 @@ enum PosixCommand { Recv(posix::Recv), } -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] enum SysvCommand { Create(sysv::Create), Info(sysv::Info), @@ -32,7 +32,7 @@ enum SysvCommand { Unlink(sysv::Unlink), } -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] #[clap( version = crate_version!(), author = crate_authors!(", "), diff --git a/src/posix/create.rs b/src/posix/create.rs index be4606b..9a09922 100644 --- a/src/posix/create.rs +++ b/src/posix/create.rs @@ -1,11 +1,11 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use log::{info, log_enabled, Level::Info}; use posixmq::PosixMq; use std::fs; /// Create a POSIX message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Create { /// Permissions (octal) to create the queue with #[clap(short, long)] diff --git a/src/posix/info.rs b/src/posix/info.rs index abf9641..7ab01e1 100644 --- a/src/posix/info.rs +++ b/src/posix/info.rs @@ -1,9 +1,9 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use posixmq::PosixMq; /// Print information about an existing message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Info { /// Name of the queue #[clap(value_name = "QUEUE")] diff --git a/src/posix/list.rs b/src/posix/list.rs index f9c02b6..57fa45d 100644 --- a/src/posix/list.rs +++ b/src/posix/list.rs @@ -1,11 +1,11 @@ use anyhow::{anyhow, Result}; use chrono::{DateTime, Local}; -use clap::Clap; +use clap::Parser; use log::warn; use std::{fs, os::unix::fs::PermissionsExt}; /// Print a list of existing message queues -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct List { /// Show all parameters #[clap(short, long)] diff --git a/src/posix/recv.rs b/src/posix/recv.rs index 6d83cef..c3abb66 100644 --- a/src/posix/recv.rs +++ b/src/posix/recv.rs @@ -1,13 +1,13 @@ use anyhow::Result; use chrono::{DateTime, Local}; -use clap::Clap; +use clap::Parser; use humantime::Duration; use log::info; use posixmq::PosixMq; use std::str; /// Receive and print a message from a message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Recv { /// Do not block #[clap(short, long)] diff --git a/src/posix/send.rs b/src/posix/send.rs index d6feefc..fcfad4f 100644 --- a/src/posix/send.rs +++ b/src/posix/send.rs @@ -1,11 +1,11 @@ use anyhow::Result; use chrono::DateTime; -use clap::Clap; +use clap::Parser; use humantime::Duration; use log::info; /// Send a message to a message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Send { /// Set a different priority, priority >= 0 #[clap(short, long, default_value = "0")] diff --git a/src/posix/unlink.rs b/src/posix/unlink.rs index 4b89a27..cc21287 100644 --- a/src/posix/unlink.rs +++ b/src/posix/unlink.rs @@ -1,9 +1,9 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use log::info; /// Delete a message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Unlink { /// Name of the queue #[clap(value_name = "QUEUE")] diff --git a/src/sysv/create.rs b/src/sysv/create.rs index e4b03a6..676cdcb 100644 --- a/src/sysv/create.rs +++ b/src/sysv/create.rs @@ -1,10 +1,10 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use log::info; use sysvmq::SysvMq; /// Create a SysV message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Create { /// Permissions (octal) to create the queue with (default: 0644) #[clap(short, long)] diff --git a/src/sysv/info.rs b/src/sysv/info.rs index 42d9fac..9bd0420 100644 --- a/src/sysv/info.rs +++ b/src/sysv/info.rs @@ -1,12 +1,12 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use std::{ fs::File, io::{BufRead, BufReader}, }; /// Print information about an existing message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Info { /// Id of the queue #[clap(short, long, required_unless_present_any = &["key"], conflicts_with = "key")] diff --git a/src/sysv/list.rs b/src/sysv/list.rs index 9f66951..7c12f16 100644 --- a/src/sysv/list.rs +++ b/src/sysv/list.rs @@ -1,12 +1,12 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use std::{ fs::File, io::{BufRead, BufReader}, }; /// Print a list of existing message queues -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct List {} impl List { diff --git a/src/sysv/unlink.rs b/src/sysv/unlink.rs index 8723d20..9b4b998 100644 --- a/src/sysv/unlink.rs +++ b/src/sysv/unlink.rs @@ -1,9 +1,9 @@ use anyhow::Result; -use clap::Clap; +use clap::Parser; use log::info; /// Delete a message queue -#[derive(Clap, Debug)] +#[derive(Debug, Parser)] pub struct Unlink { /// Id of the queue #[clap( From 8f93d2d6c8d10d07e91738a62e182bc8dfb5aa75 Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 3 Dec 2021 14:57:38 +0100 Subject: [PATCH 11/11] Fix clippy and remove borrows Fix clippy lints and remove unneded borrows when logging or printing macros. --- src/posix/create.rs | 10 +++++----- src/posix/info.rs | 2 +- src/posix/send.rs | 12 ++++++------ src/posix/unlink.rs | 2 +- src/sysv/create.rs | 2 +- src/sysv/info.rs | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/posix/create.rs b/src/posix/create.rs index 9a09922..cceabde 100644 --- a/src/posix/create.rs +++ b/src/posix/create.rs @@ -40,7 +40,7 @@ impl Create { let mq = &mut posixmq::OpenOptions::readonly(); if let Some(m) = &self.mode { - mq.mode(u32::from_str_radix(&m, 8)?); + mq.mode(u32::from_str_radix(m, 8)?); } mq.max_msg_len(self.msgsize.unwrap_or_else(msgsize_default)) @@ -53,10 +53,10 @@ impl Create { let attributes = mq.attributes()?; info!("Created message queue: {} with attributes msgsize: {}, capacity: {}, current_messages: {}", - &self.queue, - &attributes.max_msg_len, - &attributes.capacity, - &attributes.current_messages); + self.queue, + attributes.max_msg_len, + attributes.capacity, + attributes.current_messages); } Ok(()) diff --git a/src/posix/info.rs b/src/posix/info.rs index 7ab01e1..2a95f6b 100644 --- a/src/posix/info.rs +++ b/src/posix/info.rs @@ -16,7 +16,7 @@ impl Info { println!( "Message queue: {}, msg_max: {}, msgsize_max: {}, current_messages: {}", - &self.queue, &attrs.capacity, &attrs.max_msg_len, &attrs.current_messages + self.queue, attrs.capacity, attrs.max_msg_len, attrs.current_messages ); Ok(()) diff --git a/src/posix/send.rs b/src/posix/send.rs index fcfad4f..6dd70de 100644 --- a/src/posix/send.rs +++ b/src/posix/send.rs @@ -38,24 +38,24 @@ impl Send { if let Some(timeout) = &self.timeout { mq.open(&self.queue)?.send_timeout( self.priority, - &self.msg.as_bytes(), + self.msg.as_bytes(), *timeout.parse::()?, )?; - info!("Sent message: \"{}\" to queue: {}", &self.msg, &self.queue); + info!("Sent message: \"{}\" to queue: {}", self.msg, self.queue); } else if let Some(deadline) = &self.deadline { mq.open(&self.queue)?.send_deadline( self.priority, - &self.msg.as_bytes(), + self.msg.as_bytes(), DateTime::parse_from_str(deadline, "%Y-%m-%d %H:%M:%S")?.into(), )?; - info!("Sent message: \"{}\" to queue: {}", &self.msg, &self.queue); + info!("Sent message: \"{}\" to queue: {}", self.msg, self.queue); } else { mq.open(&self.queue)? - .send(self.priority, &self.msg.as_bytes())?; + .send(self.priority, self.msg.as_bytes())?; - info!("Sent message: \"{}\" to queue: {}", &self.msg, &self.queue); + info!("Sent message: \"{}\" to queue: {}", self.msg, self.queue); } Ok(()) diff --git a/src/posix/unlink.rs b/src/posix/unlink.rs index cc21287..75a8bd2 100644 --- a/src/posix/unlink.rs +++ b/src/posix/unlink.rs @@ -14,7 +14,7 @@ impl Unlink { pub fn run(&self) -> Result<()> { posixmq::remove_queue(&self.queue)?; - info!("Removed message queue: {}", &self.queue); + info!("Removed message queue: {}", self.queue); Ok(()) } diff --git a/src/sysv/create.rs b/src/sysv/create.rs index 676cdcb..4adad77 100644 --- a/src/sysv/create.rs +++ b/src/sysv/create.rs @@ -19,7 +19,7 @@ impl Create { let mut mq = SysvMq::::new(); if let Some(m) = &self.mode { - mq.mode(i32::from_str_radix(&m, 8)?); + mq.mode(i32::from_str_radix(m, 8)?); } mq.create(self.key)?; diff --git a/src/sysv/info.rs b/src/sysv/info.rs index 9bd0420..77d4b3e 100644 --- a/src/sysv/info.rs +++ b/src/sysv/info.rs @@ -28,7 +28,7 @@ impl Info { pub fn run(&self) -> Result<()> { let mut lines = BufReader::new(File::open("/proc/sysvipc/msg")?).lines(); - print_line(&lines.nth(0).unwrap_or(Ok(String::new()))?); + print_line(&lines.next().unwrap_or_else(|| Ok(String::new()))?); for line in lines { let line = line?;