diff --git a/src/timeout.rs b/src/timeout.rs index 4caba84a9..ed2424796 100644 --- a/src/timeout.rs +++ b/src/timeout.rs @@ -60,6 +60,17 @@ impl From for i32 { impl FromStr for Timeout { type Err = ParseIntError; + /// Convert a string to a number + /// + /// Takes either "default", "never" or a positive number and converts it to `Timeout` + /// # Example + /// ``` + /// # use notify_rust::Timeout; + /// # use std::str::FromStr; + /// assert_eq!(Timeout::from_str("default").unwrap(), Timeout::Default); + /// assert_eq!(Timeout::from_str("never").unwrap(), Timeout::Never); + /// assert_eq!(Timeout::from_str("1000").unwrap(), Timeout::Milliseconds(1000)); + /// ``` fn from_str(s: &str) -> Result { match s { "default" => Ok(Timeout::Default),