diff --git a/src/ephemeral.rs b/src/ephemeral.rs index c546b72d7..42bf9cb28 100644 --- a/src/ephemeral.rs +++ b/src/ephemeral.rs @@ -66,6 +66,7 @@ use std::cmp::max; use std::collections::BTreeSet; use std::fmt; use std::num::ParseIntError; +use std::str::FromStr; use std::time::{Duration, UNIX_EPOCH}; use anyhow::{Context as _, Result, ensure}; @@ -123,12 +124,6 @@ impl Timer { Self::Enabled { duration } } } - - /// Tries to parse a string as an integer, - /// and converts it to an ephemeral timer value. - pub fn from_str(input: &str) -> Result { - input.parse::().map(Self::from_u32) - } } impl fmt::Display for Timer { @@ -137,6 +132,14 @@ impl fmt::Display for Timer { } } +impl FromStr for Timer { + type Err = ParseIntError; + + fn from_str(input: &str) -> Result { + input.parse::().map(Self::from_u32) + } +} + impl rusqlite::types::ToSql for Timer { fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Integer(match self { diff --git a/src/receive_imf.rs b/src/receive_imf.rs index f1a68e23c..812d1a78f 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -3,6 +3,7 @@ use std::cmp; use std::collections::{BTreeMap, BTreeSet}; use std::iter; +use std::str::FromStr as _; use std::sync::LazyLock; use anyhow::{Context as _, Result, ensure};