Struct dfir_rs::scheduled::ticks::TickDuration
source · pub struct TickDuration {
pub ticks: i64,
}
Expand description
The duration between two ticks.
TickDuration
instances can be negative to allow for calculation of TickInstant
instances in the past.
assert_eq!(TickInstant(1) + TickDuration::new(-1), TickInstant(0))
TickDuration
instances can be added/subtracted to/from other TickDuration
instances
assert_eq!(TickDuration::ZERO + TickDuration::ZERO, TickDuration::ZERO);
assert_eq!(
TickDuration::ZERO + TickDuration::SINGLE_TICK,
TickDuration::SINGLE_TICK
);
assert_eq!(
TickDuration::SINGLE_TICK - TickDuration::ZERO,
TickDuration::SINGLE_TICK
);
assert_eq!(
TickDuration::SINGLE_TICK - TickDuration::SINGLE_TICK,
TickDuration::ZERO
);
assert_eq!(
TickDuration::ZERO - TickDuration::SINGLE_TICK,
-TickDuration::SINGLE_TICK
);
Fields§
§ticks: i64
The length of the duration, measured in ticks.
Implementations§
source§impl TickDuration
impl TickDuration
sourcepub const ZERO: Self = _
pub const ZERO: Self = _
A zero duration
It is the identity element for addition for both TickDuration
and
TickInstant
(i.e. adding zero duration to a TickInstant
or TickDuration
results in
the same TickInstant
or TickDuration
.
let ticks = TickInstant::new(100);
assert_eq!(ticks + TickDuration::ZERO, ticks);
assert_eq!(ticks - TickDuration::ZERO, ticks);
let duration = TickDuration::new(100);
assert_eq!(duration + TickDuration::ZERO, duration);
assert_eq!(duration - TickDuration::ZERO, duration);
sourcepub const SINGLE_TICK: Self = _
pub const SINGLE_TICK: Self = _
A single tick duration.
It is the duration between two consecutive TickInstant
instances.
assert_eq!(TickInstant(0) + TickDuration::SINGLE_TICK, TickInstant(1))
sourcepub fn new(ticks: i64) -> TickDuration
pub fn new(ticks: i64) -> TickDuration
Create a new TickDuration
for the specified tick interval.
A negative duration allows for calculating TickInstants
in the past and represents a
backward movement in time.
Trait Implementations§
source§impl Add<TickDuration> for TickInstant
impl Add<TickDuration> for TickInstant
source§type Output = TickInstant
type Output = TickInstant
The resulting type after applying the
+
operator.source§impl Add for TickDuration
impl Add for TickDuration
source§impl AddAssign<TickDuration> for TickInstant
impl AddAssign<TickDuration> for TickInstant
source§fn add_assign(&mut self, rhs: TickDuration)
fn add_assign(&mut self, rhs: TickDuration)
Performs the
+=
operation. Read moresource§impl AddAssign for TickDuration
impl AddAssign for TickDuration
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl Clone for TickDuration
impl Clone for TickDuration
source§fn clone(&self) -> TickDuration
fn clone(&self) -> TickDuration
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TickDuration
impl Debug for TickDuration
source§impl Default for TickDuration
impl Default for TickDuration
source§fn default() -> TickDuration
fn default() -> TickDuration
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for TickDuration
impl<'de> Deserialize<'de> for TickDuration
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for TickDuration
impl Display for TickDuration
source§impl From<TickDuration> for i64
impl From<TickDuration> for i64
source§fn from(value: TickDuration) -> Self
fn from(value: TickDuration) -> Self
Converts to this type from the input type.
source§impl Hash for TickDuration
impl Hash for TickDuration
source§impl Neg for TickDuration
impl Neg for TickDuration
source§impl Ord for TickDuration
impl Ord for TickDuration
source§fn cmp(&self, other: &TickDuration) -> Ordering
fn cmp(&self, other: &TickDuration) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for TickDuration
impl PartialEq for TickDuration
source§impl PartialOrd for TickDuration
impl PartialOrd for TickDuration
source§impl Serialize for TickDuration
impl Serialize for TickDuration
source§impl Sub<TickDuration> for TickInstant
impl Sub<TickDuration> for TickInstant
source§type Output = TickInstant
type Output = TickInstant
The resulting type after applying the
-
operator.source§impl Sub for TickDuration
impl Sub for TickDuration
source§impl SubAssign<TickDuration> for TickInstant
impl SubAssign<TickDuration> for TickInstant
source§fn sub_assign(&mut self, rhs: TickDuration)
fn sub_assign(&mut self, rhs: TickDuration)
Performs the
-=
operation. Read moresource§impl SubAssign for TickDuration
impl SubAssign for TickDuration
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for TickDuration
impl Eq for TickDuration
impl StructuralPartialEq for TickDuration
Auto Trait Implementations§
impl Freeze for TickDuration
impl RefUnwindSafe for TickDuration
impl Send for TickDuration
impl Sync for TickDuration
impl Unpin for TickDuration
impl UnwindSafe for TickDuration
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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