pub fn parse<R: Read>(source: R) -> Result<Run> {
    let splits: Splits = from_reader(source).context(Json)?;

    let mut run = Run::new();

    if splits.Category.starts_with("Portal 2") {
        run.set_game_name("Portal 2");
    } else if splits.Category.starts_with("Portal") {
        run.set_game_name("Portal");
    } else if splits.Category.starts_with("Half Life 2") {
        run.set_game_name("Half Life 2");
    }

    if let Some(run_name) = splits.RunName {
        if run_name != splits.Category {
            run.set_category_name(run_name);
        } else {
            run.set_category_name(splits.Category);
        }
    } else {
        run.set_category_name(splits.Category);
    }

    if let Some(segments) = splits.Splits {
        for split in segments {
            let name = if let Some(name) = split.Name {
                name.to_owned()
            } else {
                split.Map.to_owned()
            };

            let mut segment = Segment::new(name);

            if let Some(ticks) = split.Ticks {
                let pb_split_time = Some(time_span_from_ticks(run.category_name(), ticks));
                segment.set_personal_best_split_time(GameTime(pb_split_time).into());
            }

            if let Some(best) = split.BestSegment {
                let best_segment_time = Some(time_span_from_ticks(run.category_name(), best));
                segment.set_best_segment_time(GameTime(best_segment_time).into());
            }

            run.push_segment(segment);
        }
    }

    Ok(run)
}
/// Attempts to parse a SourceLiveTimer splits file.
Attempts to parse a SourceLiveTimer splits file.
Attempts to parse a SourceLiveTimer splits file .
pub fn parse<R: Read>(source: R) -> Result<Run> {
    let splits: Splits = from_reader(source).context(Json)?;
    let mut run = Run::new();
    if splits.Category.starts_with("Portal 2") {
        run.set_game_name("Portal 2");
    } else if splits.Category.starts_with("Portal") {
        run.set_game_name("Portal");
    } else if splits.Category.starts_with("Half Life 2") {
        run.set_game_name("Half Life 2");
    }
    if let Some(run_name) = splits.RunName {
        if run_name != splits.Category {
            run.set_category_name(run_name);
        } else {
            run.set_category_name(splits.Category);
        }
    } else {
        run.set_category_name(splits.Category);
    }
    if let Some(segments) = splits.Splits {
        for split in segments {
            let name = if let Some(name) = split.Name {
                name.to_owned()
            } else {
                split.Map.to_owned()
            };
            let mut segment = Segment::new(name);
            if let Some(ticks) = split.Ticks {
                let pb_split_time = Some(time_span_from_ticks(run.category_name(), ticks));
                segment.set_personal_best_split_time(GameTime(pb_split_time).into());
            }
            if let Some(best) = split.BestSegment {
                let best_segment_time = Some(time_span_from_ticks(run.category_name(), best));
                segment.set_best_segment_time(GameTime(best_segment_time).into());
            }
            run.push_segment(segment);
        }
    }
    Ok(run)
}
pub fn parse < R : Read > ( source : R ) -> Result < Run > { let splits : Splits = from_reader ( source ) . context ( Json ) ? ; let mut run = Run :: new ( ) ; if splits . Category . starts_with ( " " ) { run . set_game_name ( " " ) ; } else if splits . Category . starts_with ( " " ) { run . set_game_name ( " " ) ; } else if splits . Category . starts_with ( " " ) { run . set_game_name ( " " ) ; } if let Some ( run_name ) = splits . RunName { if run_name != splits . Category { run . set_category_name ( run_name ) ; } else { run . set_category_name ( splits . Category ) ; } } else { run . set_category_name ( splits . Category ) ; } if let Some ( segments ) = splits . Splits { for split in segments { let name = if let Some ( name ) = split . Name { name . to_owned ( ) } else { split . Map . to_owned ( ) } ; let mut segment = Segment :: new ( name ) ; if let Some ( ticks ) = split . Ticks { let pb_split_time = Some ( time_span_from_ticks ( run . category_name ( ) , ticks ) ) ; segment . set_personal_best_split_time ( GameTime ( pb_split_time ) . into ( ) ) ; } if let Some ( best ) = split . BestSegment { let best_segment_time = Some ( time_span_from_ticks ( run . category_name ( ) , best ) ) ; segment . set_best_segment_time ( GameTime ( best_segment_time ) . into ( ) ) ; } run . push_segment ( segment ) ; } } Ok ( run ) }
Attempts to parse a SourceLiveTimer splits file.
Attempts to parse a SourceLiveTimer splits file .
source
R
source
R