Struct livesplit_core::Segment
source · pub struct Segment { /* private fields */ }
Expand description
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.
Examples
use livesplit_core::{Segment, Time, TimeSpan};
let mut segment = Segment::new("Metro Kingdom");
let time = Time::new().with_real_time(Some(TimeSpan::from_seconds(234.0)));
segment.set_personal_best_split_time(time);
Implementations§
source§impl Segment
impl Segment
sourcepub fn new<S>(name: S) -> Selfwhere
S: Into<String>,
pub fn new<S>(name: S) -> Selfwhere
S: Into<String>,
Creates a new Segment with the name given.
sourcepub fn set_name<S>(&mut self, name: S)where
S: PopulateString,
pub fn set_name<S>(&mut self, name: S)where
S: PopulateString,
Sets the name of the segment.
sourcepub fn comparisons_mut(&mut self) -> &mut Comparisons
pub fn comparisons_mut(&mut self) -> &mut Comparisons
Grants mutable access to the comparison times stored in the Segment. This includes both the custom comparisons and the generated ones.
sourcepub fn comparison_mut(&mut self, comparison: &str) -> &mut Time
pub fn comparison_mut(&mut self, comparison: &str) -> &mut Time
Grants mutable access to the specified comparison’s time. If there’s none for this comparison, a new one is inserted with an empty time.
sourcepub fn comparison(&self, comparison: &str) -> Time
pub fn comparison(&self, comparison: &str) -> Time
Accesses the specified comparison’s time. If there’s none for this comparison, an empty time is being returned (but not stored in the segment).
sourcepub fn comparison_timing_method(
&self,
comparison: &str,
method: TimingMethod
) -> Option<TimeSpan>
pub fn comparison_timing_method(
&self,
comparison: &str,
method: TimingMethod
) -> Option<TimeSpan>
Accesses the given timing method of the specified comparison. If either
the TimeSpan is empty or the comparison has no stored time, None
is
returned.
sourcepub fn personal_best_split_time(&self) -> Time
pub fn personal_best_split_time(&self) -> Time
Accesses the split time of the Personal Best for this segment. If it doesn’t exist, an empty time is returned.
sourcepub fn personal_best_split_time_mut(&mut self) -> &mut Time
pub fn personal_best_split_time_mut(&mut self) -> &mut Time
Grants mutable access to the split time of the Personal Best for this segment. If it doesn’t exist an empty time is inserted.
sourcepub fn set_personal_best_split_time(&mut self, time: Time)
pub fn set_personal_best_split_time(&mut self, time: Time)
Sets the split time of the Personal Best to the time provided.
sourcepub const fn best_segment_time(&self) -> Time
pub const fn best_segment_time(&self) -> Time
Accesses the Best Segment Time.
sourcepub fn best_segment_time_mut(&mut self) -> &mut Time
pub fn best_segment_time_mut(&mut self) -> &mut Time
Grants mutable access to the Best Segment Time.
sourcepub fn set_best_segment_time(&mut self, time: Time)
pub fn set_best_segment_time(&mut self, time: Time)
Sets the Best Segment Time.
sourcepub const fn split_time(&self) -> Time
pub const fn split_time(&self) -> Time
Accesses the split time of the current attempt.
sourcepub fn split_time_mut(&mut self) -> &mut Time
pub fn split_time_mut(&mut self) -> &mut Time
Grants mutable access to the split time of the current attempt.
sourcepub fn set_split_time(&mut self, time: Time)
pub fn set_split_time(&mut self, time: Time)
Sets the split time of the current attempt.
sourcepub fn clear_split_time(&mut self)
pub fn clear_split_time(&mut self)
Clears the split time of the current attempt.
sourcepub const fn segment_history(&self) -> &SegmentHistory
pub const fn segment_history(&self) -> &SegmentHistory
Accesses the Segment History of this segment.
sourcepub fn segment_history_mut(&mut self) -> &mut SegmentHistory
pub fn segment_history_mut(&mut self) -> &mut SegmentHistory
Grants mutable access to the Segment History of this segment.
sourcepub const fn variables(&self) -> &HashMap<String, String>
pub const fn variables(&self) -> &HashMap<String, String>
Accesses the segment’s variables for the current attempt.
sourcepub fn variables_mut(&mut self) -> &mut HashMap<String, String>
pub fn variables_mut(&mut self) -> &mut HashMap<String, String>
Grants mutable access to the segment’s variables for the current attempt.
sourcepub fn clear_variables(&mut self)
pub fn clear_variables(&mut self)
Clears the variables of the current attempt.
sourcepub fn clear_split_info(&mut self)
pub fn clear_split_info(&mut self)
Clears all the information the segment stores when it has been splitted, such as the split’s time and variables.
Trait Implementations§
source§impl PartialEq<Segment> for Segment
impl PartialEq<Segment> for Segment
impl StructuralPartialEq for Segment
Auto Trait Implementations§
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnwindSafe for Segment
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.