continuwuity/src/admin/debug/tester.rs
Jason Volk 4f8fec7e5a
replace admin command branches returning RoomMessageEventContent
rename admin Command back to Context

Signed-off-by: Jason Volk <jason@zemos.net>
2025-04-19 23:33:52 +01:00

52 lines
850 B
Rust

use conduwuit::{Err, Result};
use crate::{admin_command, admin_command_dispatch};
#[admin_command_dispatch]
#[derive(Debug, clap::Subcommand)]
pub(crate) enum TesterCommand {
Panic,
Failure,
Tester,
Timer,
}
#[rustfmt::skip]
#[admin_command]
async fn panic(&self) -> Result {
panic!("panicked")
}
#[rustfmt::skip]
#[admin_command]
async fn failure(&self) -> Result {
Err!("failed")
}
#[inline(never)]
#[rustfmt::skip]
#[admin_command]
async fn tester(&self) -> Result {
self.write_str("Ok").await
}
#[inline(never)]
#[rustfmt::skip]
#[admin_command]
async fn timer(&self) -> Result {
let started = std::time::Instant::now();
timed(self.body);
let elapsed = started.elapsed();
self.write_str(&format!("completed in {elapsed:#?}")).await
}
#[inline(never)]
#[rustfmt::skip]
#[allow(unused_variables)]
fn timed(body: &[&str]) {
}