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
livesplit_core::auto_splitting::Runtime provides a runtime for WebAssembly auto splitters — small WASM modules that read game memory and automatically control the timer (start, split, reset, set game time, etc.) without any manual input from the runner.
The auto-splitting runtime requires the
auto-splitting Cargo feature. Without it the type still exists but all operations return errors.Only one auto splitter can be loaded at a time. Calling
load while another auto splitter is running replaces it immediately.Requirements for Auto Splitter Modules
Auto splitter WASM modules must export anupdate function with this signature:
memory.
The auto splitter communicates with the host through functions provided in the env module — timer control, process memory reading, settings access, and logging.
Construction
Runtime::new() -> Runtime<T>
Starts the auto-splitting runtime and background threads. Does not load an auto splitter yet — call load separately.
The type parameter T must implement event::CommandSink + TimerQuery + Send + 'static. When used with the standard SharedTimer, use Runtime<SharedTimer>.
Loading and Unloading
load(path: PathBuf, timer: T) -> Result<(), Error>
Loads a WASM auto splitter file from disk and starts running it. The file is read, compiled, and instantiated. If a previous auto splitter was loaded, it is replaced. Returns an error if the file cannot be read (Error::ReadFileFailed) or if the WASM module fails to compile or instantiate (Error::LoadFailed).
unload() -> Result<(), Error>
Stops and unloads the current auto splitter. Returns Ok(()) if no auto splitter was loaded (unloading an absent auto splitter is not an error). Returns Err(Error::ThreadStopped) only if the background thread has unexpectedly stopped.
Watchdog
The runtime spawns a dedicated watchdog thread alongside the auto-splitting thread. The watchdog monitors the auto splitter’s tick timestamps. If the auto splitter fails to tick within the expected window, the watchdog unloads it automatically to prevent the timer from becoming unresponsive. This behavior is transparent — you don’t need to configure the watchdog manually.Error Types
Full Rust Example
C API
The C API wrapsRuntime<SharedTimer> behind an opaque OwnedAutoSplittingRuntime pointer. Note that the C load function takes a path string and a SharedTimer object directly.
| C function | Rust equivalent |
|---|---|
AutoSplittingRuntime_new() | Runtime::new() |
AutoSplittingRuntime_load(this, path, shared_timer) | runtime.load(path, timer) — returns bool |
AutoSplittingRuntime_unload(this) | runtime.unload() — returns bool |
AutoSplittingRuntime_drop(this) | drop(runtime) |
When the
auto-splitting Cargo feature is not enabled, AutoSplittingRuntime_new still returns a valid (non-null) object, but AutoSplittingRuntime_load and AutoSplittingRuntime_unload always return false.Cargo Feature
Add the feature flag to yourCargo.toml to enable the auto-splitting runtime: