Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LiveSplit/livesplit-core/llms.txt

Use this file to discover all available pages before exploring further.

Overview

A Segment represents a single split point in a speedrun — the moment the runner presses their split key. Each segment stores:
  • A name (e.g. "Forgotten Crossroads")
  • An optional icon
  • Split times for every comparison (the cumulative time at which the runner hit this split)
  • A best segment time (the fastest individual segment time across all attempts)
  • A segment history — a record of individual segment times from every past attempt
A Run is an ordered list of Segment values. The last segment’s split time is the final time for the whole run.

Construction

Segment::new<S: Into<String>>(name: S) -> Segment

Creates a new segment with the given name. All time fields start empty.
let segment = Segment::new("Forgotten Crossroads");

Name

name(&self) -> &str

Returns the name of the segment.

set_name<S: PopulateString>(&mut self, name: S)

Sets the name of the segment.
segment.set_name("Greenpath");

Split Times

Split times in livesplit-core use the Time struct, which wraps both a real_time: Option<TimeSpan> and a game_time: Option<TimeSpan>. Either or both may be None if not recorded.

personal_best_split_time(&self) -> Time

Returns the cumulative split time for the "Personal Best" comparison. This is the time at which the runner reached this segment in their personal best run. Returns an empty Time if no PB is set.

set_personal_best_split_time(&mut self, time: Time)

Sets the split time for the Personal Best comparison.

best_segment_time(&self) -> Time

Returns the best (fastest) individual segment time recorded across all attempts — not cumulative, just the time spent on this one segment. Returns an empty Time if none is recorded.

best_segment_time_mut(&mut self) -> &mut Time

Provides mutable access to the best segment time.

set_best_segment_time(&mut self, time: Time)

Sets the best segment time.

split_time(&self) -> Time

Returns the cumulative split time for the current attempt (set live by the timer). This is cleared when an attempt ends or is reset.

set_split_time(&mut self, time: Time)

Sets the split time for the current attempt.

clear_split_time(&mut self)

Clears the split time for the current attempt (resets it to empty).

comparison(&self, comparison: &str) -> Time

Returns the split time for any named comparison. If this segment has no time stored for that comparison, an empty Time is returned (it is not inserted into the segment).
let average_time = segment.comparison("Average Segments");

comparison_mut(&mut self, comparison: &str) -> &mut Time

Returns a mutable reference to the specified comparison’s time. If none exists, an empty time is inserted first.

comparison_timing_method(&self, comparison: &str, method: TimingMethod) -> Option<TimeSpan>

Returns the TimeSpan for a specific comparison and timing method. Returns None if either the comparison has no entry or the timing method’s value is empty.

Icon

icon(&self) -> &Image

Returns the segment’s icon. If no icon has been set, the image data is empty.

set_icon(&mut self, image: Image)

Sets the segment’s icon.

Segment History

The segment history records the individual time spent on this segment during each past attempt (not cumulative — just the delta for this one segment).

segment_history(&self) -> &SegmentHistory

Returns an immutable reference to the segment’s history. SegmentHistory is an ordered map of attempt index → Time.

segment_history_mut(&mut self) -> &mut SegmentHistory

Returns a mutable reference to the segment history, allowing history entries to be added, removed, or edited directly.

Attempt Variables

Segments can store arbitrary key-value string pairs for the current attempt. These are set by auto splitters and are cleared at the end of each attempt.

variables(&self) -> &HashMap<String, String>

Returns the current attempt’s variable map.

variables_mut(&mut self) -> &mut HashMap<String, String>

Returns a mutable reference to the variable map.

clear_variables(&mut self)

Removes all variables for the current attempt.

clear_split_info(&mut self)

Convenience method — clears both the current attempt’s split time and all variables. Called by the timer when resetting.

Code Example

use livesplit_core::{Segment, Time, TimeSpan};

let mut segment = Segment::new("Forgotten Crossroads");

// Set PB split time
let pb_time = Time::new()
    .with_real_time(Some(TimeSpan::from_seconds(42.5)));
segment.set_personal_best_split_time(pb_time);

// Set best segment time
let best = Time::new()
    .with_real_time(Some(TimeSpan::from_seconds(38.2)));
segment.set_best_segment_time(best);

println!("Segment: {}", segment.name());

Build docs developers (and LLMs) love