fn parse_configuration<'a>(s: &'a str) -> Option<AlarmConfig> {
    let x = s.split(";");
    let split: Vec<&str> = x.collect();
    let last_run = chrono::Local::now();

    let maybe_config: Option<AlarmConfig> = match split.as_slice() {
        [the_days, the_time, the_audio, the_volume] => {
            let time_opt = parse_time(the_time);

            let selected_days_opt: Option<Vec<bool>> = parse_days(the_days);
            let volume = parse_int_with_min_max(the_volume,0 ,100);
            match (selected_days_opt, time_opt) {
                (Some(selected_days), Some(time)) => {
                    let cfg = AlarmConfig {
                        days: selected_days,
                        time,
                        audio_file: the_audio.to_string(),
                        volume,
                        last_run
                    };
                    Some(cfg)
                },
                _ => {
                    println!("Days or time invalid");
                    None
                }
            }
        },
        _ => {
            println!("Invalid configuration: {}", s);
            None
        }
    };

    maybe_config
}
/// Parses a string line to an alarm config
Parses a string line to an alarm config
Parses a string line to an alarm config
fn parse_configuration<'a>(s: &'a str) -> Option<AlarmConfig> {
    let x = s.split(";");
    let split: Vec<&str> = x.collect();
    let last_run = chrono::Local::now();
    let maybe_config: Option<AlarmConfig> = match split.as_slice() {
        [the_days, the_time, the_audio, the_volume] => {
            let time_opt = parse_time(the_time);
            let selected_days_opt: Option<Vec<bool>> = parse_days(the_days);
            let volume = parse_int_with_min_max(the_volume,0 ,100);
            match (selected_days_opt, time_opt) {
                (Some(selected_days), Some(time)) => {
                    let cfg = AlarmConfig {
                        days: selected_days,
                        time,
                        audio_file: the_audio.to_string(),
                        volume,
                        last_run
                    };
                    Some(cfg)
                },
                _ => {
                    println!("Days or time invalid");
                    None
                }
            }
        },
        _ => {
            println!("Invalid configuration: {}", s);
            None
        }
    };
    maybe_config
}
fn parse_configuration < ' a > ( s : & ' a str ) -> Option < AlarmConfig > { let x = s . split ( " " ) ; let split : Vec < & str > = x . collect ( ) ; let last_run = chrono :: Local :: now ( ) ; let maybe_config : Option < AlarmConfig > = match split . as_slice ( ) { [ the_days , the_time , the_audio , the_volume ] => { let time_opt = parse_time ( the_time ) ; let selected_days_opt : Option < Vec < bool > > = parse_days ( the_days ) ; let volume = parse_int_with_min_max ( the_volume , 0 , 100 ) ; match ( selected_days_opt , time_opt ) { ( Some ( selected_days ) , Some ( time ) ) => { let cfg = AlarmConfig { days : selected_days , time , audio_file : the_audio . to_string ( ) , volume , last_run } ; Some ( cfg ) } , _ => { println ! ( " " ) ; None } } } , _ => { println ! ( " " s ) ; None } } ; maybe_config }
Parses a string line to an alarm config
Parses a string line to an alarm config
s
&'a str
s
&'a str