#[repr(transparent)]
#[derive(Debug, Clone)]
pub struct MonitorPolicy {
enabled: bool,
}
impl MonitorPolicy {
#[must_use]
pub const fn enabled() -> Self {
Self { enabled: true }
}
#[must_use]
pub const fn disabled() -> Self {
Self { enabled: false }
}
#[cfg(test)]
pub(crate) const fn is_enabled(&self) -> bool {
self.enabled
}
}
impl Default for MonitorPolicy {
fn default() -> Self {
Self::enabled()
}
}
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))] mod tests {
use super::*;
#[test]
fn default_policy_enables_monitoring() {
assert!(MonitorPolicy::default().is_enabled());
}
#[test]
fn disabled_policy_disables_monitoring() {
assert!(!MonitorPolicy::disabled().is_enabled());
}
}