Compare commits
No commits in common. "8f93d2d6c8d10d07e91738a62e182bc8dfb5aa75" and "d5ef64171a530bb7e0de96235978da56003eccc9" have entirely different histories.
8f93d2d6c8
...
d5ef64171a
13 changed files with 64 additions and 70 deletions
52
Cargo.lock
generated
52
Cargo.lock
generated
|
@ -13,9 +13,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.51"
|
||||
version = "1.0.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
|
||||
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
|
@ -42,9 +42,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.72"
|
||||
version = "1.0.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
|
@ -67,9 +67,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.0-beta.5"
|
||||
version = "3.0.0-beta.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "feff3878564edb93745d58cf63e17b63f24142506e7a20c87a5521ed7bfb1d63"
|
||||
checksum = "fcd70aa5597dbc42f7217a543f9ef2768b2ef823ba29036072d30e1d88e98406"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
|
@ -80,14 +80,14 @@ dependencies = [
|
|||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
"unicase",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.0.0-beta.5"
|
||||
version = "3.0.0-beta.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b15c6b4f786ffb6192ffe65a36855bc1fc2444bcd0945ae16748dcd6ed7d0d3"
|
||||
checksum = "0b5bb0d655624a0b8770d1c178fb8ffcb1f91cc722cb08f451e3dc72465421ac"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
|
@ -157,9 +157,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.108"
|
||||
version = "0.2.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119"
|
||||
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
|
@ -233,12 +233,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "4.2.0"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "addaa943333a514159c80c97ff4a93306530d965d27e139188283cd13e06a799"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d"
|
||||
|
||||
[[package]]
|
||||
name = "posixmq"
|
||||
|
@ -275,9 +272,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.32"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
|
||||
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
@ -316,9 +313,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.82"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
|
||||
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -383,15 +380,6 @@ 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"
|
||||
|
@ -410,6 +398,12 @@ 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"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
name = "mqrs"
|
||||
version = "0.1.1"
|
||||
authors = ["finga <mqrs@onders.org>"]
|
||||
edition = "2021"
|
||||
edition = "2018"
|
||||
repository = "https://git.onders.org/finga/mqrs"
|
||||
license = "GPL-3.0-or-later"
|
||||
readme = "README.md"
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,10 +1,10 @@
|
|||
use anyhow::Result;
|
||||
use clap::{crate_authors, crate_version, AppSettings, Parser};
|
||||
use clap::{crate_authors, crate_version, AppSettings, Clap};
|
||||
|
||||
mod posix;
|
||||
mod sysv;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
enum Backend {
|
||||
/// Handle POSIX message queues
|
||||
#[clap(subcommand)]
|
||||
|
@ -14,7 +14,7 @@ enum Backend {
|
|||
Sysv(SysvCommand),
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
enum PosixCommand {
|
||||
Create(posix::Create),
|
||||
Info(posix::Info),
|
||||
|
@ -24,7 +24,7 @@ enum PosixCommand {
|
|||
Recv(posix::Recv),
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
enum SysvCommand {
|
||||
Create(sysv::Create),
|
||||
Info(sysv::Info),
|
||||
|
@ -32,7 +32,7 @@ enum SysvCommand {
|
|||
Unlink(sysv::Unlink),
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
#[clap(
|
||||
version = crate_version!(),
|
||||
author = crate_authors!(", "),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use log::{info, log_enabled, Level::Info};
|
||||
use posixmq::PosixMq;
|
||||
use std::fs;
|
||||
|
||||
/// Create a POSIX message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Create {
|
||||
/// Permissions (octal) to create the queue with
|
||||
#[clap(short, long)]
|
||||
|
@ -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(())
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use posixmq::PosixMq;
|
||||
|
||||
/// Print information about an existing message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Info {
|
||||
/// Name of the queue
|
||||
#[clap(value_name = "QUEUE")]
|
||||
|
@ -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(())
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use chrono::{DateTime, Local};
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use log::warn;
|
||||
use std::{fs, os::unix::fs::PermissionsExt};
|
||||
|
||||
/// Print a list of existing message queues
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct List {
|
||||
/// Show all parameters
|
||||
#[clap(short, long)]
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use anyhow::Result;
|
||||
use chrono::{DateTime, Local};
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use humantime::Duration;
|
||||
use log::info;
|
||||
use posixmq::PosixMq;
|
||||
use std::str;
|
||||
|
||||
/// Receive and print a message from a message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Recv {
|
||||
/// Do not block
|
||||
#[clap(short, long)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use anyhow::Result;
|
||||
use chrono::DateTime;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use humantime::Duration;
|
||||
use log::info;
|
||||
|
||||
/// Send a message to a message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Send {
|
||||
/// Set a different priority, priority >= 0
|
||||
#[clap(short, long, default_value = "0")]
|
||||
|
@ -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::<Duration>()?,
|
||||
)?;
|
||||
|
||||
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(())
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use log::info;
|
||||
|
||||
/// Delete a message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Unlink {
|
||||
/// Name of the queue
|
||||
#[clap(value_name = "QUEUE")]
|
||||
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use log::info;
|
||||
use sysvmq::SysvMq;
|
||||
|
||||
/// Create a SysV message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Create {
|
||||
/// Permissions (octal) to create the queue with (default: 0644)
|
||||
#[clap(short, long)]
|
||||
|
@ -19,7 +19,7 @@ impl Create {
|
|||
let mut mq = SysvMq::<String>::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)?;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
};
|
||||
|
||||
/// Print information about an existing message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Info {
|
||||
/// Id of the queue
|
||||
#[clap(short, long, required_unless_present_any = &["key"], conflicts_with = "key")]
|
||||
|
@ -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.next().unwrap_or_else(|| Ok(String::new()))?);
|
||||
print_line(&lines.nth(0).unwrap_or(Ok(String::new()))?);
|
||||
|
||||
for line in lines {
|
||||
let line = line?;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
};
|
||||
|
||||
/// Print a list of existing message queues
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct List {}
|
||||
|
||||
impl List {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::Clap;
|
||||
use log::info;
|
||||
|
||||
/// Delete a message queue
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Unlink {
|
||||
/// Id of the queue
|
||||
#[clap(
|
||||
|
|
Loading…
Reference in a new issue