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

    let mut run = Run::new();

    run.set_game_name(splits.game.name);
    run.set_category_name(splits.game.category);
    run.metadata_mut().set_platform_name(splits.game.platform);
    run.metadata_mut().set_region_name(splits.game.region);

    // FIXME: Region may need to be translated to speedrun.com's region.
    // FIXME: Parse pause times.
    // FIXME: Parse default timing method, if we ever store that.

    if let Some(start_delay) = splits.start_delay {
        run.set_offset(TimeSpan::from_milliseconds(-start_delay as _));
    }

    let (mut total_rta, mut total_igt) = (TimeSpan::zero(), TimeSpan::zero());

    for split in splits.segments {
        let mut segment = Segment::new(split.name);

        if !split.skipped {
            if let Some(personal_best) = split.personal_best {
                segment.set_personal_best_split_time(parse_split_time(
                    &mut total_rta,
                    &mut total_igt,
                    personal_best,
                ));
            }
        }

        if let Some(overall_best) = split.overall_best {
            segment.set_best_segment_time(parse_best_segment_time(overall_best));
        }

        run.push_segment(segment);
    }

    Ok(run)
}
/// Attempts to parse a Splitterino splits file.
Attempts to parse a Splitterino splits file.
Attempts to parse a Splitterino splits file .
pub fn parse<R: Read>(source: R) -> Result<Run> {
    let SplitsFormat { splits, .. } = from_reader(source).context(Json)?;
    let mut run = Run::new();
    run.set_game_name(splits.game.name);
    run.set_category_name(splits.game.category);
    run.metadata_mut().set_platform_name(splits.game.platform);
    run.metadata_mut().set_region_name(splits.game.region);
    // FIXME: Region may need to be translated to speedrun.com's region.
    // FIXME: Parse pause times.
    // FIXME: Parse default timing method, if we ever store that.
    if let Some(start_delay) = splits.start_delay {
        run.set_offset(TimeSpan::from_milliseconds(-start_delay as _));
    }
    let (mut total_rta, mut total_igt) = (TimeSpan::zero(), TimeSpan::zero());
    for split in splits.segments {
        let mut segment = Segment::new(split.name);
        if !split.skipped {
            if let Some(personal_best) = split.personal_best {
                segment.set_personal_best_split_time(parse_split_time(
                    &mut total_rta,
                    &mut total_igt,
                    personal_best,
                ));
            }
        }
        if let Some(overall_best) = split.overall_best {
            segment.set_best_segment_time(parse_best_segment_time(overall_best));
        }
        run.push_segment(segment);
    }
    Ok(run)
}
pub fn parse < R : Read > ( source : R ) -> Result < Run > { let SplitsFormat { splits , .. } = from_reader ( source ) . context ( Json ) ? ; let mut run = Run :: new ( ) ; run . set_game_name ( splits . game . name ) ; run . set_category_name ( splits . game . category ) ; run . metadata_mut ( ) . set_platform_name ( splits . game . platform ) ; run . metadata_mut ( ) . set_region_name ( splits . game . region ) ; // FIXME: Region may need to be translated to speedrun.com's region. // FIXME: Parse pause times. // FIXME: Parse default timing method, if we ever store that. if let Some ( start_delay ) = splits . start_delay { run . set_offset ( TimeSpan :: from_milliseconds ( - start_delay as _ ) ) ; } let ( mut total_rta , mut total_igt ) = ( TimeSpan :: zero ( ) , TimeSpan :: zero ( ) ) ; for split in splits . segments { let mut segment = Segment :: new ( split . name ) ; if ! split . skipped { if let Some ( personal_best ) = split . personal_best { segment . set_personal_best_split_time ( parse_split_time ( & mut total_rta , & mut total_igt , personal_best , ) ) ; } } if let Some ( overall_best ) = split . overall_best { segment . set_best_segment_time ( parse_best_segment_time ( overall_best ) ) ; } run . push_segment ( segment ) ; } Ok ( run ) }
Attempts to parse a Splitterino splits file.
Attempts to parse a Splitterino splits file .
source
R
source
R