Skip to main content

LimitsExt

Trait LimitsExt 

Source
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§

Source

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)

Source

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

Source

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)

Implementors§