Struct livesplit_core::run::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
impl Run
sourcepub fn set_game_name<S>(&mut self, name: S)where
S: PopulateString,
pub fn set_game_name<S>(&mut self, name: S)where
S: PopulateString,
Sets the name of the game this Run is for.
sourcepub fn set_game_icon<D: Into<Image>>(&mut self, image: D)
pub fn set_game_icon<D: Into<Image>>(&mut self, image: D)
Sets the game’s icon.
sourcepub fn category_name(&self) -> &str
pub fn category_name(&self) -> &str
Accesses the name of the category this Run is for.
sourcepub fn set_category_name<S>(&mut self, name: S)where
S: PopulateString,
pub fn set_category_name<S>(&mut self, name: S)where
S: PopulateString,
Sets the name of the category this Run is for.
sourcepub const fn attempt_count(&self) -> u32
pub const fn attempt_count(&self) -> u32
Returns the amount of runs that have been attempted with these splits.
sourcepub fn set_attempt_count(&mut self, attempts: u32)
pub fn set_attempt_count(&mut self, attempts: u32)
Sets the amount of runs that have been attempted with these splits.
sourcepub const fn metadata(&self) -> &RunMetadata
pub const fn metadata(&self) -> &RunMetadata
Accesses additional metadata of this Run, like the platform and region of the game.
sourcepub fn metadata_mut(&mut self) -> &mut RunMetadata
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.
sourcepub fn set_offset(&mut self, offset: TimeSpan)
pub fn set_offset(&mut self, offset: TimeSpan)
Sets the time an attempt of this Run should start at.
sourcepub const fn offset(&self) -> TimeSpan
pub const fn offset(&self) -> TimeSpan
Accesses the time an attempt of this Run should start at.
sourcepub fn start_next_run(&mut self)
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.
sourcepub fn segments_mut(&mut self) -> &mut Vec<Segment> ⓘ
pub fn segments_mut(&mut self) -> &mut Vec<Segment> ⓘ
Grants mutable access to the Segments of this Run object.
sourcepub fn push_segment(&mut self, segment: Segment)
pub fn push_segment(&mut self, segment: Segment)
Pushes the segment provided to the end of the list of segments of this Run.
sourcepub fn segment_mut(&mut self, index: usize) -> &mut Segment
pub fn segment_mut(&mut self, index: usize) -> &mut Segment
sourcepub fn attempt_history(&self) -> &[Attempt]
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.
sourcepub fn custom_comparisons(&self) -> &[String]
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.
sourcepub fn custom_comparisons_mut(&mut self) -> &mut Vec<String> ⓘ
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.
sourcepub fn comparisons(&self) -> ComparisonsIter<'_> ⓘ
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.
sourcepub fn comparison_generators(&self) -> &[Box<dyn ComparisonGenerator>]
pub fn comparison_generators(&self) -> &[Box<dyn ComparisonGenerator>]
Accesses the Comparison Generators in use by this Run.
sourcepub fn comparison_generators_mut(
&mut self
) -> &mut Vec<Box<dyn ComparisonGenerator>> ⓘ
pub fn comparison_generators_mut(
&mut self
) -> &mut Vec<Box<dyn ComparisonGenerator>> ⓘ
Grants mutable access to the Comparison Generators in use by this Run.
sourcepub fn auto_splitter_settings(&self) -> &str
pub fn auto_splitter_settings(&self) -> &str
Accesses the Auto Splitter Settings that are encoded as XML.
sourcepub fn auto_splitter_settings_mut(&mut self) -> &mut String
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.
sourcepub fn mark_as_modified(&mut self)
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.
sourcepub fn mark_as_unmodified(&mut self)
pub fn mark_as_unmodified(&mut self)
Marks the Run as unmodified, so that it is known that all the changes have been saved.
sourcepub const fn has_been_modified(&self) -> bool
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.
sourcepub fn add_attempt(
&mut self,
time: Time,
started: Option<AtomicDateTime>,
ended: Option<AtomicDateTime>,
pause_time: Option<TimeSpan>
)
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.
sourcepub fn add_attempt_with_index(
&mut self,
time: Time,
index: i32,
started: Option<AtomicDateTime>,
ended: Option<AtomicDateTime>,
pause_time: Option<TimeSpan>
)
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.
sourcepub fn clear_run_id(&mut self)
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.
sourcepub fn add_custom_comparison<S>(&mut self, comparison: S) -> ComparisonResult<()>where
S: PopulateString,
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.
sourcepub fn regenerate_comparisons(&mut self)
pub fn regenerate_comparisons(&mut self)
Recalculates all the comparison times the Comparison Generators provide.
sourcepub fn extended_file_name(&self, use_extended_category_name: bool) -> String
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.
sourcepub fn extended_name(&self, use_extended_category_name: bool) -> Cow<'_, str>
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.
sourcepub const fn extended_category_name(
&self,
show_region: bool,
show_platform: bool,
show_variables: bool
) -> ExtendedCategoryName<'_>
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)
sourcepub fn max_attempt_history_index(&self) -> Option<i32>
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.
sourcepub fn fix_splits(&mut self)
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.
sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clears out the Attempt History and the Segment Histories of all the segments.
sourcepub fn clear_times(&mut self)
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.
sourcepub fn min_segment_history_index(&self) -> Option<i32>
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.
sourcepub fn import_pb_into_segment_history(&mut self)
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.
sourcepub fn import_best_segment(&mut self, segment_index: usize)
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.
sourcepub fn update_segment_history(&mut self, current_split_index: usize)
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.
sourcepub fn validate_comparison_name(&self, new: &str) -> ComparisonResult<()>
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 TotalPlaytime for Run
impl TotalPlaytime for Run
source§fn total_playtime(&self) -> TimeSpan
fn total_playtime(&self) -> TimeSpan
impl StructuralPartialEq for Run
Auto Trait Implementations§
impl !RefUnwindSafe for Run
impl Send for Run
impl Sync for Run
impl Unpin for Run
impl !UnwindSafe for Run
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.