cleanup and fix earlier introduced scoping error

This commit is contained in:
dignifiedquire
2019-09-15 12:08:07 +02:00
committed by holger krekel
parent 6be3c9a48a
commit e710836276
5 changed files with 205 additions and 228 deletions

View File

@@ -4,6 +4,7 @@ use std::str;
use num_traits::FromPrimitive;
use crate::dc_mimeparser::SystemMessage;
use crate::error;
/// Available param keys.
@@ -178,6 +179,13 @@ impl Params {
self.get(key).and_then(|s| s.parse().ok())
}
/// Get the parameter behind `Param::Cmd` interpreted as `SystemMessage`.
pub fn get_cmd(&self) -> SystemMessage {
self.get_int(Param::Cmd)
.and_then(SystemMessage::from_i32)
.unwrap_or_default()
}
/// Get the given parameter and parse as `f64`.
pub fn get_float(&self, key: Param) -> Option<f64> {
self.get(key).and_then(|s| s.parse().ok())