Files
continuwuity/src/admin/debug/tester.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.0 KiB
Rust
Raw Normal View History

2024-12-14 21:58:01 -05:00
use conduwuit::Err;
2024-04-29 13:56:04 -07:00
use ruma::events::room::message::RoomMessageEventContent;
use crate::{Result, admin_command, admin_command_dispatch};
2024-04-29 13:56:04 -07:00
2024-07-27 00:11:41 +00:00
#[admin_command_dispatch]
#[derive(Debug, clap::Subcommand)]
2024-06-23 09:06:25 +00:00
pub(crate) enum TesterCommand {
2024-08-28 04:09:46 +00:00
Panic,
Failure,
2024-04-29 13:56:04 -07:00
Tester,
2024-06-23 07:11:00 +00:00
Timer,
}
2024-08-28 04:09:46 +00:00
#[rustfmt::skip]
#[admin_command]
async fn panic(&self) -> Result<RoomMessageEventContent> {
panic!("panicked")
}
#[rustfmt::skip]
#[admin_command]
async fn failure(&self) -> Result<RoomMessageEventContent> {
Err!("failed")
}
2024-06-23 07:11:00 +00:00
#[inline(never)]
#[rustfmt::skip]
2024-07-27 00:11:41 +00:00
#[admin_command]
async fn tester(&self) -> Result<RoomMessageEventContent> {
2024-06-23 07:11:00 +00:00
2025-01-04 16:57:07 +00:00
Ok(RoomMessageEventContent::notice_plain("legacy"))
2024-06-23 07:11:00 +00:00
}
#[inline(never)]
#[rustfmt::skip]
2024-07-27 00:11:41 +00:00
#[admin_command]
async fn timer(&self) -> Result<RoomMessageEventContent> {
2024-06-23 07:11:00 +00:00
let started = std::time::Instant::now();
2024-07-27 00:11:41 +00:00
timed(self.body);
2024-06-23 07:11:00 +00:00
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
}