use kithara_platform::time::Duration;
use serde::Serialize;
pub trait HangDump {
fn dump_json(&self) -> String;
fn label(&self) -> Option<&str> {
None
}
}
impl<T: Serialize> HangDump for T {
fn dump_json(&self) -> String {
serde_json::to_string(self).unwrap_or_else(|_| "{}".into())
}
}
#[derive(Debug, Default, Clone, Copy)]
pub struct NoContext;
impl Serialize for NoContext {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_unit_struct("NoContext")
}
}
#[must_use]
pub fn default_timeout() -> Duration {
const FALLBACK_TIMEOUT: Duration = Duration::from_secs(10);
super::platform::env_timeout().unwrap_or(FALLBACK_TIMEOUT)
}