feat(cmd_duration): Make notification timeout configurable (#3515)

* Allow customization of notification timeout

* Document new notification duration option

* Check for out-of-bounds timeout and correct it

* Implement ModuleConfig for u32

* Revert "Check for out-of-bounds timeout and correct it"

This reverts commit 52109ab5f7.

* Switch notification_timeout to u32

* Note notification_daemons might not honor timout

* Notification timeout defaults to daemon timeout

* Leave default value of notification_timeout blank in docs
This commit is contained in:
Lyndon Sanche
2022-01-29 14:56:55 -07:00
committed by GitHub
parent 6ca911b9fe
commit e680540cfc
4 changed files with 37 additions and 10 deletions
+17
View File
@@ -109,6 +109,23 @@ impl<'a> ModuleConfig<'a> for f64 {
}
}
impl<'a> ModuleConfig<'a> for u32 {
fn from_config(config: &Value) -> Option<Self> {
match config {
Value::Integer(value) => {
// Converting i64 to u32
if *value > 0 && *value <= u32::MAX.into() {
Some(*value as Self)
} else {
None
}
}
Value::String(value) => value.parse::<Self>().ok(),
_ => None,
}
}
}
impl<'a> ModuleConfig<'a> for usize {
fn from_config(config: &Value) -> Option<Self> {
match config {