Run

Struct Run 

Source
pub struct Run { /* private fields */ }
Expand description

A Run stores the split times for a specific game and category of a runner.

§Examples

use livesplit_core::{Run, Segment};

let mut run = Run::new();

run.set_game_name("Super Mario Odyssey");
run.set_category_name("Darker Side");

run.push_segment(Segment::new("Cap Kingdom"));
run.push_segment(Segment::new("Cascade Kingdom"));

Implementations§

Source§

impl Run

Source

pub fn new() -> Self

Creates a new Run object with no segments.

Source

pub fn game_name(&self) -> &str

Accesses the name of the game this Run is for.

Source

pub fn set_game_name<S>(&mut self, name: S)
where S: PopulateString,

Sets the name of the game this Run is for.

Source

pub const fn game_icon(&self) -> &Image

Accesses the game’s icon.

Source

pub fn set_game_icon<D: Into<Image>>(&mut self, image: D)

Sets the game’s icon.

Source

pub fn category_name(&self) -> &str

Accesses the name of the category this Run is for.

Source

pub fn set_category_name<S>(&mut self, name: S)
where S: PopulateString,

Sets the name of the category this Run is for.

Source

pub const fn attempt_count(&self) -> u32

Returns the amount of runs that have been attempted with these splits.

Source

pub fn set_attempt_count(&mut self, attempts: u32)

Sets the amount of runs that have been attempted with these splits.

Source

pub const fn metadata(&self) -> &RunMetadata

Accesses additional metadata of this Run, like the platform and region of the game.

Source

pub fn metadata_mut(&mut self) -> &mut RunMetadata

Grants mutable access to the additional metadata of this Run, like the platform and region of the game.

Source

pub fn set_offset(&mut self, offset: TimeSpan)

Sets the time an attempt of this Run should start at.

Source

pub const fn offset(&self) -> TimeSpan

Accesses the time an attempt of this Run should start at.

Source

pub fn start_next_run(&mut self)

Marks a Run that a new Attempt has started. If you use it with a Timer, this is done automatically.

Source

pub fn segments(&self) -> &[Segment]

Accesses the Segments of this Run object.

Source

pub fn segments_mut(&mut self) -> &mut Vec<Segment>

Grants mutable access to the Segments of this Run object.

Source

pub fn push_segment(&mut self, segment: Segment)

Pushes the segment provided to the end of the list of segments of this Run.

Source

pub fn segment(&self, index: usize) -> &Segment

Accesses a certain segment of this Run.

§Panics

Panics if the index is out of bounds.

Source

pub fn segment_mut(&mut self, index: usize) -> &mut Segment

Mutably accesses a certain segment of this Run.

§Panics

Panics if the index is out of bounds.

Source

pub fn attempt_history(&self) -> &[Attempt]

Accesses the history of all the runs that have been attempted. This does not store the actual segment times, just the overall attempt information. Information about the individual segments is stored within each segment.

Source

pub fn custom_comparisons(&self) -> &[String]

Accesses the custom comparisons that are stored in this Run. This includes Personal Best but excludes all the other Comparison Generators.

Source

pub fn custom_comparisons_mut(&mut self) -> &mut Vec<String>

Grants mutable access to the custom comparisons that are stored in this Run. This includes Personal Best but excludes all the other Comparison Generators.

§Warning

You may not delete the Personal Best comparison.

Source

pub fn comparisons(&self) -> ComparisonsIter<'_>

Accesses an iterator that iterates over all the comparisons. This includes both the custom comparisons defined by the user and the Comparison Generators.

Source

pub fn comparison_generators(&self) -> &[Box<dyn ComparisonGenerator>]

Accesses the Comparison Generators in use by this Run.

Source

pub fn comparison_generators_mut( &mut self, ) -> &mut Vec<Box<dyn ComparisonGenerator>>

Grants mutable access to the Comparison Generators in use by this Run.

Source

pub fn auto_splitter_settings(&self) -> &str

Accesses the Auto Splitter Settings that are encoded as XML.

Source

pub fn auto_splitter_settings_mut(&mut self) -> &mut String

Grants mutable access to the XML encoded Auto Splitter Settings.

§Warning

You need to ensure that the Auto Splitter Settings are encoded as data that would be valid as an interior of an XML element.

Source

pub fn len(&self) -> usize

Returns the amount of segments stored in this Run.

Source

pub fn is_empty(&self) -> bool

Returns true if there’s no segments stored in this Run.

Source

pub fn mark_as_modified(&mut self)

Marks the Run as modified, so that it is known that there are changes that should be saved.

Source

pub fn mark_as_unmodified(&mut self)

Marks the Run as unmodified, so that it is known that all the changes have been saved.

Source

pub const fn has_been_modified(&self) -> bool

Returns whether the Run has been modified and should be saved so that the changes don’t get lost.

Source

pub fn add_attempt( &mut self, time: Time, started: Option<AtomicDateTime>, ended: Option<AtomicDateTime>, pause_time: Option<TimeSpan>, )

Adds a new Attempt to the Run’s Attempt History. This is automatically done if the Run is used with a Timer.

Source

pub fn add_attempt_with_index( &mut self, time: Time, index: i32, started: Option<AtomicDateTime>, ended: Option<AtomicDateTime>, pause_time: Option<TimeSpan>, )

Adds a new Attempt to the Run’s Attempt History with a predetermined History Index.

§Warning

This index may not overlap with an index that is already in the Attempt History.

Source

pub fn clear_run_id(&mut self)

Clears the speedrun.com Run ID of this Run, as the current Run does not reflect the run on speedrun.com anymore. This may be the case if a new Personal Best is achieved for example.

Source

pub fn add_custom_comparison<S>( &mut self, comparison: S, ) -> ComparisonResult<()>
where S: PopulateString,

Adds a new custom comparison. If a custom comparison with that name already exists, it is not added.

Source

pub fn regenerate_comparisons(&mut self)

Recalculates all the comparison times the Comparison Generators provide.

Source

pub fn extended_file_name(&self, use_extended_category_name: bool) -> String

Returns a file name (without the extension) suitable for this Run that is built the following way:

Game Name - Category Name

If either is empty, the dash is omitted. Special characters that cause problems in file names are also omitted. If an extended category name is used, the variables of the category are appended in a parenthesis.

Source

pub fn extended_name(&self, use_extended_category_name: bool) -> Cow<'_, str>

Returns a name suitable for this Run that is built the following way:

Game Name - Category Name

If either is empty, the dash is omitted. If an extended category name is used, the variables of the category are appended in a parenthesis.

Source

pub const fn extended_category_name( &self, show_region: bool, show_platform: bool, show_variables: bool, ) -> ExtendedCategoryName<'_>

Returns an extended category name that possibly includes the region, platform and variables, depending on the arguments provided. The returned object implements Display where it lazily formats the extended category name. An extended category name may look like this:

Any% (No Tuner, JPN, Wii Emulator)

Source

pub fn max_attempt_history_index(&self) -> Option<i32>

Returns the maximum index currently in use by the Attempt History. This mostly serves as a helper function for the Timer.

Source

pub fn fix_splits(&mut self)

Applies some fixing algorithms on the Run. This includes fixing the comparison times and history, removing duplicates in the segment histories and removing empty times.

Source

pub fn clear_history(&mut self)

Clears out the Attempt History and the Segment Histories of all the segments.

Source

pub fn clear_times(&mut self)

Clears out the Attempt History, the Segment Histories, all the times, sets the Attempt Count to 0 and clears the speedrun.com run id association. All Custom Comparisons other than Personal Best are deleted as well.

Source

pub fn min_segment_history_index(&self) -> Option<i32>

Returns the minimum index in use by all the Segment Histories. None is returned if the Run has no segments.

Source

pub fn import_pb_into_segment_history(&mut self)

Fixes the Segment History by calculating the segment times from the Personal Best times and adding those to the Segment History.

Source

pub fn import_best_segment(&mut self, segment_index: usize)

Fixes a segment’s Segment History by adding its Best Segment Time to its Segment History.

§Panics

This panics if the segment index provided is out of bounds.

Source

pub fn update_segment_history(&mut self, current_split_index: usize)

Updates the Segment History by adding the split times of the most recent attempt up to the provided current split index to the Segment History.

§Panics

This panics if there is no attempt in the Attempt History.

Source

pub fn validate_comparison_name(&self, new: &str) -> ComparisonResult<()>

Checks a given name against the current comparisons in the Run to ensure that it is valid for use.

Trait Implementations§

Source§

impl Clone for Run

Source§

fn clone(&self) -> Run

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Run

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Run

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Run

Source§

fn eq(&self, other: &Run) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TotalPlaytime for Run

Source§

fn total_playtime(&self) -> TimeSpan

Calculates the total playtime.
Source§

impl StructuralPartialEq for Run

Auto Trait Implementations§

§

impl Freeze for Run

§

impl !RefUnwindSafe for Run

§

impl Send for Run

§

impl Sync for Run

§

impl Unpin for Run

§

impl !UnwindSafe for Run

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetSetFdFlags for T

Source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
Source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
Source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,