[][src]Crate livesplit_core

livesplit-core is a library that provides a lot of functionality for creating a speedrun timer.

Examples

use livesplit_core::{Run, Segment, Timer, TimerPhase};

// Create a run object that we can use with at least one segment.
let mut run = Run::new();
run.set_game_name("Super Mario Odyssey");
run.set_category_name("Any%");
run.push_segment(Segment::new("Cap Kingdom"));

// Create the timer from the run.
let mut timer = Timer::new(run).expect("Run with at least one segment provided");

// Start a new attempt.
timer.start();
assert_eq!(timer.current_phase(), TimerPhase::Running);

// Create a split.
timer.split();

// The run should be finished now.
assert_eq!(timer.current_phase(), TimerPhase::Ended);

// Reset the attempt and confirm that we want to store the attempt.
timer.reset(true);

// The attempt is now over.
assert_eq!(timer.current_phase(), TimerPhase::NotRunning);

Re-exports

pub use crate::layout::Editor as LayoutEditor;
pub use crate::layout::Layout;
pub use crate::run::Editor as RunEditor;
pub use crate::run::Run;
pub use indexmap;
pub use livesplit_hotkey as hotkey;
pub use palette;
pub use parking_lot;

Modules

analysis

The analysis module provides a variety of functions for calculating information about runs.

comparison

The comparison module provides all the different automatically generated comparisons, like the Best Segments and the Average Segments. Additionally, functions for dealing with comparisons, like shortening a comparison, are provided.

component

The component module provides all the different components available. A Component allows querying different kinds of information from a Timer. This information is provided as state objects in a way that can easily be visualized by any kind of User Interface.

layout

The layout module provides everything necessary for working with Layouts. A Layout allows you to combine multiple components together to visualize a variety of information the runner is interested in.

run

The run module provides everything necessary for working with Runs, like parsing and saving or editing them.

settings

The settings module provides the ability to customize components and various other settings.

timing

The timing module provides everything necessary for working with times and measuring them.

Structs

AtomicDateTime

An Atomic Date Time represents a UTC Date Time that tries to be as close to an atomic clock as possible.

Attempt

An Attempt describes information about an attempt to run a specific category by a specific runner in the past. Every time a new attempt is started and then reset, an Attempt describing general information about it is created.

DateTime

ISO 8601 combined date and time with time zone.

GameTime

Represents a Time Span intended to be used as a Game Time.

GeneralLayoutSettings

The general settings of the layout that apply to all components.

HotkeyConfig

The configuration to use for a Hotkey System. It describes with keys to use as hotkeys for the different actions.

HotkeySystem

With a Hotkey System the runner can use hotkeys on their keyboard to control the Timer. The hotkeys are global, so the application doesn't need to be in focus. The behavior of the hotkeys depends on the platform and is stubbed out on platforms that don't support hotkeys. You can turn off a Hotkey System temporarily. By default the Hotkey System is activated.

Image

Images can be used to store segment and game icons. Each image object comes with an ID that changes whenever the image is modified. IDs are unique across different images. You can query the image's data as a Data URL. There's no specific image format you need to use for the images.

RealTime

Represents a Time Span intended to be used as a Real Time.

RunMetadata

The Run Metadata stores additional information about a run, like the platform and region of the game. All of this information is optional.

Segment

A Segment describes a point in a speedrun that is suitable for storing a split time. This stores the name of that segment, an icon, the split times of different comparisons, and a history of segment times.

SegmentHistory

Stores the segment times achieved for a certain segment. Each segment is tagged with an index. Only segment times with an index larger than 0 are considered times actually achieved by the runner, while the others are artifacts of route changes and similar algorithmic changes.

Time

A time that can store a Real Time and a Game Time. Both of them are optional.

TimeSpan

A Time Span represents a certain span of time.

TimeStamp

A Time Stamp stores a point in time, that can be used to calculate Time Spans.

Timer

A Timer provides all the capabilities necessary for doing speedrun attempts.

Utc

The UTC time zone. This is the most efficient time zone when you don't need the local time. It is also used as an offset (which is also a dummy type).

Enums

CachedImageId

With a Cached Image ID you can track image changes. It starts with an uncached state and then gets updated with the images provided to it. It can be reset at any point in order to force a change to be detected.

Component

A Component provides information about a run in a way that is easy to visualize. This type can store any of the components provided by this crate.

TimerPhase

Describes which phase the timer is currently in. This tells you if there's an active speedrun attempt and whether it is paused or it ended.

TimingMethod

A Timing Method describes which form of timing is used. This can either be Real Time or Game Time.

Type Definitions

SharedTimer

A Shared Timer is a wrapper around the Timer that can be shared across multiple threads with multiple owners.