use crate::{AtomicDateTime, Time, TimeSpan};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Attempt {
index: i32,
time: Time,
started: Option<AtomicDateTime>,
ended: Option<AtomicDateTime>,
pause_time: Option<TimeSpan>,
}
impl Attempt {
pub const fn new(
index: i32,
time: Time,
started: Option<AtomicDateTime>,
ended: Option<AtomicDateTime>,
pause_time: Option<TimeSpan>,
) -> Self {
Self {
index,
time,
started,
ended,
pause_time,
}
}
pub fn duration(&self) -> Option<TimeSpan> {
let diff = catch! { self.ended? - self.started? };
diff.or(self.time.real_time)
}
#[inline]
pub const fn index(&self) -> i32 {
self.index
}
#[inline]
pub const fn time(&self) -> Time {
self.time
}
#[inline]
pub const fn pause_time(&self) -> Option<TimeSpan> {
self.pause_time
}
#[inline]
pub const fn started(&self) -> Option<AtomicDateTime> {
self.started
}
#[inline]
pub const fn ended(&self) -> Option<AtomicDateTime> {
self.ended
}
}