2024-04-29 13:56:04 -07:00
|
|
|
use ruma::events::room::message::RoomMessageEventContent;
|
|
|
|
|
|
|
|
use crate::Result;
|
|
|
|
|
|
|
|
#[derive(clap::Subcommand)]
|
2024-06-23 07:11:00 +00:00
|
|
|
#[cfg_attr(test, derive(Debug))]
|
2024-06-16 22:26:52 +00:00
|
|
|
pub(super) enum TesterCommands {
|
2024-04-29 13:56:04 -07:00
|
|
|
Tester,
|
2024-06-23 07:11:00 +00:00
|
|
|
Timer,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) async fn process(command: TesterCommands, body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
|
|
|
match command {
|
|
|
|
TesterCommands::Tester => tester(body).await,
|
|
|
|
TesterCommands::Timer => timer(body).await,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[allow(unused_variables)]
|
|
|
|
async fn tester(body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
|
|
|
|
|
|
|
Ok(RoomMessageEventContent::notice_plain("completed"))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[rustfmt::skip]
|
|
|
|
async fn timer(body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
|
|
|
let started = std::time::Instant::now();
|
|
|
|
timed(&body);
|
|
|
|
|
|
|
|
let elapsed = started.elapsed();
|
|
|
|
Ok(RoomMessageEventContent::notice_plain(format!("completed in {elapsed:#?}")))
|
2024-04-29 13:56:04 -07:00
|
|
|
}
|
2024-06-23 07:11:00 +00:00
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[allow(unused_variables)]
|
|
|
|
fn timed(body: &[&str]) {
|
|
|
|
|
2024-04-29 13:56:04 -07:00
|
|
|
}
|