mqrs/src/info.rs
2021-06-20 16:35:20 +02:00

24 lines
578 B
Rust

use anyhow::Result;
use clap::Clap;
use posixmq::PosixMq;
/// Print information about an existing message queue
#[derive(Clap, Debug)]
pub struct Info {
/// Name of the queue
#[clap(value_name = "QUEUE")]
pub queue: String,
}
impl Info {
pub fn run(&self) -> Result<()> {
let attrs = PosixMq::open(&self.queue)?.attributes()?;
println!(
"Message queue: {}, msg_max: {}, msgsize_max: {}, current_messages: {}",
&self.queue, &attrs.capacity, &attrs.max_msg_len, &attrs.current_messages
);
Ok(())
}
}