+/livesplit-wrapper
git clone https://git.julia.blue/+/livesplit-wrapper
b0170e4
gh-pages
1<!DOCTYPE html >< html lang ="en ">< head >< meta charset ="utf-8 ">< meta name ="viewport "content ="width=device-width, initial-scale=1.0 ">< meta name ="generator "content ="rustdoc ">< meta name ="description "content ="LiveSplit One uses dynamically loaded WASM modules for plugins, which means they have to communicate over a C api. This crate contains ergonomic wrappers and helpers to write those plugins in safe rust. At the moment only autosplitters are supported, but there will eventually be support for more general plugins. ">< meta name ="keywords "content ="rust, rustlang, rust-lang, livesplit_wrapper ">< title > livesplit_wrapper - Rust</ title >< link rel ="preload "as ="font "type ="font/woff2 "crossorigin href ="../SourceSerif4-Regular.ttf.woff2 ">< link rel ="preload "as ="font "type ="font/woff2 "crossorigin href ="../FiraSans-Regular.woff2 ">< link rel ="preload "as ="font "type ="font/woff2 "crossorigin href ="../FiraSans-Medium.woff2 ">< link rel ="preload "as ="font "type ="font/woff2 "crossorigin href ="../SourceCodePro-Regular.ttf.woff2 ">< link rel ="preload "as ="font "type ="font/woff2 "crossorigin href ="../SourceSerif4-Bold.ttf.woff2 ">< link rel ="preload "as ="font "type ="font/woff2 "crossorigin href ="../SourceCodePro-Semibold.ttf.woff2 ">< link rel ="stylesheet "href ="../normalize.css ">< link rel ="stylesheet "href ="../rustdoc.css "id ="mainThemeStyle ">< link rel ="stylesheet "href ="../ayu.css "disabled >< link rel ="stylesheet "href ="../dark.css "disabled >< link rel ="stylesheet "href ="../light.css "id ="themeStyle ">< script id ="default-settings "></ script >< script src ="../storage.js "></ script >< script defer src ="../crates.js "></ script >< script defer src ="../main.js "></ script >< noscript >< link rel ="stylesheet "href ="../noscript.css "></ noscript >< link rel ="alternate icon "type ="image/png "href ="../favicon-16x16.png ">< link rel ="alternate icon "type ="image/png "href ="../favicon-32x32.png ">< link rel ="icon "type ="image/svg+xml "href ="../favicon.svg "></ head >< body class ="rustdoc mod crate "> <!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--> < nav class ="mobile-topbar ">< button class ="sidebar-menu-toggle "> ☰</ button >< a class ="sidebar-logo "href ="../livesplit_wrapper/index.html ">< div class ="logo-container ">< img src ="https://github.com/LiveSplit.png "alt ="logo "></ div ></ a >< h2 class ="location "></ h2 ></ nav >< nav class ="sidebar ">< a class ="sidebar-logo "href ="../livesplit_wrapper/index.html ">< div class ="logo-container "> 2< img src ="https://github.com/LiveSplit.png "alt ="logo "></ div ></ a >< h2 class ="location ">< a href ="# "> Crate livesplit_wrapper</ a ></ h2 >< div class ="sidebar-elems ">< div class ="block ">< ul >< li class ="version "> Version 0.1.0</ li >< li >< a id ="all-types "href ="all.html "> All Items</ a ></ li ></ ul ></ div >< section >< div class ="block ">< ul >< li >< a href ="#macros "> Macros</ a ></ li >< li >< a href ="#structs "> Structs</ a ></ li >< li >< a href ="#enums "> Enums</ a ></ li >< li >< a href ="#traits "> Traits</ a ></ li >< li >< a href ="#types "> Type Definitions</ a ></ li ></ ul ></ div ></ section ></ div ></ nav >< main >< div class ="width-limiter ">< div class ="sub-container ">< a class ="sub-logo-container "href ="../livesplit_wrapper/index.html "> 3< img src ="https://github.com/LiveSplit.png "alt ="logo "></ a >< nav class ="sub ">< form class ="search-form ">< div class ="search-container ">< span ></ span >< input class ="search-input "name ="search "autocomplete ="off "spellcheck ="false "placeholder ="Click or press ‘S’ to search, ‘?’ for more options… "type ="search ">< div id ="help-button "title ="help "tabindex ="-1 ">< button type ="button "> ?</ button ></ div >< div id ="settings-menu "tabindex ="-1 ">< a href ="../settings.html "title ="settings ">< img width ="22 "height ="22 "alt ="Change settings "src ="../wheel.svg "></ a ></ div ></ div ></ form ></ nav ></ div >< section id ="main-content "class ="content ">< div class ="main-heading ">< h1 class ="fqn ">< span class ="in-band "> Crate< a class ="mod "href ="# "> livesplit_wrapper</ a >< button id ="copy-path "onclick ="copy_path(this) "title ="Copy item path to clipboard ">< img src ="../clipboard.svg "width ="19 "height ="18 "alt ="Copy item path "></ button ></ span ></ h1 >< span class ="out-of-band ">< a class ="srclink "href ="../src/livesplit_wrapper/lib.rs.html#1-243 "> source</ a > ·< a id ="toggle-all-docs "href ="javascript:void(0) "title ="collapse all docs "> [< span class ="inner "> −</ span > ]</ a ></ span ></ div >< details class ="rustdoc-toggle top-doc "open >< summary class ="hideme ">< span > Expand description</ span ></ summary >< div class ="docblock ">< div align ="center "> 4< h1 >< strong > LiveSplit Wrapper</ strong ></ h1 > 5< p > < strong > A safe wrapper library for writing LiveSplit One autosplitters</ strong > </ p > 6< p > 7< a href ="https://github.com/p1n3appl3/livesplit-wrapper/actions/workflows/ci.yml "> 8< img src ="https://github.com/P1n3appl3/livesplit-wrapper/actions/workflows/ci.yml/badge.svg "alt ="build status "/> 9</ a > 10< a href ="https://p1n3appl3.github.io/livesplit-wrapper/livesplit_wrapper/index.html "> 11< img src ="https://img.shields.io/github/workflow/status/p1n3appl3/livesplit-wrapper/Deploy%20docs?label=docs "alt ="docs "/> 12</ a > 13< a href ="https://choosealicense.com/licenses/mit/ "> 14< img src ="https://img.shields.io/github/license/p1n3appl3/livesplit-wrapper "alt ="license "/> 15</ a > 16</ p > 17</ div > 18< p >< a href ="https://github.com/LiveSplit/livesplit-core "> LiveSplit One</ a > uses dynamically 19loaded WASM modules for plugins, which means they have to communicate over a C 20api. This crate contains ergonomic wrappers and helpers to write those plugins 21in safe rust. At the moment only autosplitters are supported, but there will 22eventually be support for more general plugins.</ p > 23< h2 id ="implementing-an-autosplitter ">< a href ="#implementing-an-autosplitter "> Implementing an autosplitter</ a ></ h2 > 24< p > To write an autosplitter you need to implement the 25< a href ="https://p1n3appl3.github.io/livesplit-wrapper/livesplit_wrapper/trait.Splitter.html ">< code > Splitter</ code ></ a > 26trait and invoke the 27< a href ="https://p1n3appl3.github.io/livesplit-wrapper/livesplit_wrapper/macro.register_autosplitter.html ">< code > register_autosplitter!</ code ></ a > 28macro on your splitter.</ p > 29< p > Here’s a full (nonsensical) example. Build this with 30< code > --target wasm32-unknown-unknown</ code > and it can be loaded by frontends such as 31< a href ="https://github.com/CryZe/livesplit-one-desktop ">< code > livesplit-one-desktop</ code ></ a > or 32< a href ="https://github.com/P1n3appl3/obs-livesplit ">< code > obs-livesplit</ code ></ a > :</ p > 33 34< div class ="example-wrap ">< pre class ="rust rust-example-rendered ">< code >< span class ="kw "> use</ span > livesplit_wrapper::{Splitter, Process, TimerState, HostFunctions}; 35 36< span class ="attribute "> #[derive(Default)] 37</ span >< span class ="kw "> struct</ span > MySplitter { 38 process:< span class ="prelude-ty "> Option</ span > <Process>, 39} 40 41< span class ="macro "> livesplit_wrapper::register_autosplitter!</ span > (MySplitter); 42< span class ="kw "> impl</ span > Splitter< span class ="kw "> for</ span > MySplitter { 43< span class ="kw "> fn</ span > new() ->< span class ="self "> Self</ span > { 44< span class ="kw "> let</ span >< span class ="kw-2 "> mut</ span > s = MySplitter::default(); 45 s.process = s.attach(< span class ="string "> "CoolGame.exe"</ span > ); 46< span class ="kw "> if</ span > s.process.is_none() { 47< span class ="macro "> log::warn!</ span > (< span class ="string "> "failed to connect to process, is the game running?"</ span > ); 48 } 49 s.set_tick_rate(< span class ="number "> 120.0</ span > ); 50 s.set_variable(< span class ="string "> "items collected"</ span > ,< span class ="string "> "0"</ span > ); 51 s 52 } 53 54< span class ="kw "> fn</ span > update(< span class ="kw-2 "> &mut</ span >< span class ="self "> self</ span > ) { 55< span class ="kw "> if let</ span >< span class ="prelude-val "> Some</ span > (p) =< span class ="kw-2 "> &</ span >< span class ="self "> self</ span > .process { 56< span class ="kw "> match</ span > (< span class ="self "> self</ span > .state(), p.read::<i16>(< span class ="number "> 0xD1DAC71C</ span > )) { 57 (TimerState::Paused,< span class ="prelude-val "> Ok</ span > (< span class ="number "> 314</ span > )) =>< span class ="self "> self</ span > .unpause(), 58 (TimerState::Running,< span class ="prelude-val "> Ok</ span > (< span class ="number "> 42</ span > )) =>< span class ="self "> self</ span > .pause(), 59< span class ="kw "> _</ span > => {} 60 } 61 } 62 } 63}</ code ></ pre ></ div > 64< p > For a real-world example, check out 65< a href ="https://github.com/P1n3appl3/climb/tree/main/auto-splitter "> this Celeste autosplitter</ a > .</ p > 66</ div ></ details >< h2 id ="macros "class ="small-section-header ">< a href ="#macros "> Macros</ a ></ h2 >< div class ="item-table ">< div class ="item-row ">< div class ="item-left module-item ">< a class ="macro "href ="macro.register_autosplitter.html "title ="livesplit_wrapper::register_autosplitter macro "> register_autosplitter</ a ></ div >< div class ="item-right docblock-short "> Wires up the necessary c interface for a type that implements< a href ="trait.Splitter.html "title ="Splitter ">< code > Splitter</ code ></ a > .</ div ></ div ></ div >< h2 id ="structs "class ="small-section-header ">< a href ="#structs "> Structs</ a ></ h2 >< div class ="item-table ">< div class ="item-row ">< div class ="item-left module-item ">< a class ="struct "href ="struct.Logger.html "title ="livesplit_wrapper::Logger struct "> Logger</ a ></ div >< div class ="item-right docblock-short "> This logger gets initialized automatically when you register an autosplitter 67and emits logs to LiveSplit’s autosplitter runtime.</ div ></ div >< div class ="item-row ">< div class ="item-left module-item ">< a class ="struct "href ="struct.OnceCell.html "title ="livesplit_wrapper::OnceCell struct "> OnceCell</ a ></ div >< div class ="item-right docblock-short "> A thread-safe cell which can be written to only once.</ div ></ div >< div class ="item-row ">< div class ="item-left module-item ">< a class ="struct "href ="struct.Process.html "title ="livesplit_wrapper::Process struct "> Process</ a ></ div >< div class ="item-right docblock-short "> A handle representing an attached process that can be used to read its 68memory.</ div ></ div ></ div >< h2 id ="enums "class ="small-section-header ">< a href ="#enums "> Enums</ a ></ h2 >< div class ="item-table ">< div class ="item-row ">< div class ="item-left module-item ">< a class ="enum "href ="enum.Error.html "title ="livesplit_wrapper::Error enum "> Error</ a ></ div >< div class ="item-right docblock-short "> Currently the only possible error is a failed memory read on the attached 69process.</ div ></ div >< div class ="item-row ">< div class ="item-left module-item ">< a class ="enum "href ="enum.TimerState.html "title ="livesplit_wrapper::TimerState enum "> TimerState</ a ></ div >< div class ="item-right docblock-short "> The possible states of the timer.</ div ></ div ></ div >< h2 id ="traits "class ="small-section-header ">< a href ="#traits "> Traits</ a ></ h2 >< div class ="item-table ">< div class ="item-row ">< div class ="item-left module-item ">< a class ="trait "href ="trait.HostFunctions.html "title ="livesplit_wrapper::HostFunctions trait "> HostFunctions</ a ></ div >< div class ="item-right docblock-short "> The autosplitter’s interface for interacting with the LiveSpilit timer.</ div ></ div >< div class ="item-row ">< div class ="item-left module-item ">< a class ="trait "href ="trait.Pod.html "title ="livesplit_wrapper::Pod trait "> Pod</ a ></ div >< div class ="item-right docblock-short "> Marker trait for “plain old data”.</ div ></ div >< div class ="item-row ">< div class ="item-left module-item ">< a class ="trait "href ="trait.Splitter.html "title ="livesplit_wrapper::Splitter trait "> Splitter</ a ></ div >< div class ="item-right docblock-short "> The main autosplitter trait.</ div ></ div ></ div >< h2 id ="types "class ="small-section-header ">< a href ="#types "> Type Definitions</ a ></ h2 >< div class ="item-table ">< div class ="item-row ">< div class ="item-left module-item ">< a class ="type "href ="type.Address.html "title ="livesplit_wrapper::Address type "> Address</ a ></ div >< div class ="item-right docblock-short "> An address in the attached processes memory.</ div ></ div >< div class ="item-row ">< div class ="item-left module-item ">< a class ="type "href ="type.Result.html "title ="livesplit_wrapper::Result type "> Result</ a ></ div >< div class ="item-right docblock-short "> The result of an attempt to read process memory.</ div ></ div ></ div ></ section ></ div ></ main >< div id ="rustdoc-vars "data-root-path ="../ "data-current-crate ="livesplit_wrapper "data-themes ="ayu,dark,light "data-resource-suffix =""data-rustdoc-version ="1.66.0-nightly (4a1467723 2022-09-23) "></ div ></ body ></ html >