use crate::{
client::{PreparedCommand, prepare_command},
resp::cmd,
};
use std::time::Duration;
pub trait DebugCommands<'a>: Sized {
#[must_use]
fn debug_sleep(self, duration: Duration) -> PreparedCommand<'a, Self, ()> {
prepare_command(self, cmd("DEBUG").arg("SLEEP").arg(duration.as_secs_f32()))
}
#[must_use]
fn debug_restart(self, delay: Option<Duration>) -> PreparedCommand<'a, Self, ()> {
prepare_command(
self,
cmd("DEBUG")
.arg("RESTART")
.arg(delay.map(|d| u64::try_from(d.as_millis()).unwrap())),
)
}
#[must_use]
fn debug_crash_and_recover(self, delay: Option<Duration>) -> PreparedCommand<'a, Self, ()> {
prepare_command(
self,
cmd("DEBUG")
.arg("CRASH-AND-RECOVER")
.arg(delay.map(|d| u64::try_from(d.as_millis()).unwrap())),
)
}
#[must_use]
fn debug_assert(self) -> PreparedCommand<'a, Self, ()> {
prepare_command(self, cmd("DEBUG").arg("ASSERT"))
}
#[must_use]
fn debug_oom(self) -> PreparedCommand<'a, Self, ()> {
prepare_command(self, cmd("DEBUG").arg("OOM"))
}
#[must_use]
fn debug_panic(self) -> PreparedCommand<'a, Self, ()> {
prepare_command(self, cmd("DEBUG").arg("PANIC"))
}
}