parse_retention

Function parse_retention 

Source
fn parse_retention(s: &str) -> Result<Retention, ConfigError>
Expand description

Parse a retention specifier string into a Retention value.

Recognizes the literals persistent, session, and scope, the duration:<value> form which yields Retention::Duration(<value>), and the max:<n> form which yields Retention::Max(n). If max:<n> contains a non-integer n, returns ConfigError::InvalidValue.

§Examples

assert_eq!(parse_retention("persistent").unwrap(), Retention::Persistent);
assert_eq!(parse_retention("duration:7d").unwrap(), Retention::Duration("7d".into()));
assert_eq!(parse_retention("max:5").unwrap(), Retention::Max(5));