pub trait LimitsExt {
// Required methods
fn threshold(&self, key: &str, default: f64) -> f64;
fn is_ignored(&self, module: &str) -> bool;
fn is_module_enabled(&self, module: &str) -> bool;
}Expand description
Extension methods for the Limits type to reduce boilerplate in modules.
Required Methods§
Sourcefn threshold(&self, key: &str, default: f64) -> f64
fn threshold(&self, key: &str, default: f64) -> f64
Get a threshold value for a module/level key, returning a default if not set.
Replaces the common pattern:
self.limits.get("module\tlevel").copied().unwrap_or(default)
Sourcefn is_ignored(&self, module: &str) -> bool
fn is_ignored(&self, module: &str) -> bool
Check whether a module is configured to be ignored (ignore value > 0).
Replaces the common pattern:
self.limits.get("module\tignore").copied().unwrap_or(0.0) > 0.0
Sourcefn is_module_enabled(&self, module: &str) -> bool
fn is_module_enabled(&self, module: &str) -> bool
Check whether a module should be created (not configured to be ignored).
Replaces the common pattern in create_modules():
limits.get("module\tignore").map_or(true, |&v| v == 0.0)