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.

48 lines
846 B
Rust
Raw Normal View History

use conduwuit::{Err, Result};
2024-04-29 13:56:04 -07:00
use crate::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)]
2025-05-24 00:28:09 +01:00
pub 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-04-29 13:56:04 -07:00
}
2024-06-23 07:11:00 +00:00
2026-08-25 12:37:13 -04:00
#[allow(clippy::unused_async_trait_impl)]
impl crate::Context<'_> {
#[rustfmt::skip]
async fn panic(&self) -> Result {
panic!("panicked")
}
2024-08-28 04:09:46 +00:00
#[rustfmt::skip]
async fn failure(&self) -> Result {
Err!("failed")
}
2024-08-28 04:09:46 +00:00
#[inline(never)]
#[rustfmt::skip]
async fn tester(&self) -> Result {
self.write_str("Ok").await
}
2024-08-28 04:09:46 +00:00
#[inline(never)]
#[rustfmt::skip]
async fn timer(&self) -> Result {
let started = std::time::Instant::now();
timed(self.body);
2024-08-28 04:09:46 +00:00
let elapsed = started.elapsed();
self.write_str(&format!("completed in {elapsed:#?}")).await
}
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
}