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

source

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);
source

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))
source

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

source§

type Output = TickInstant

The resulting type after applying the + operator.
source§

fn add(self, rhs: TickDuration) -> Self::Output

Performs the + operation. Read more
source§

impl Add for TickDuration

source§

type Output = TickDuration

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<TickDuration> for TickInstant

source§

fn add_assign(&mut self, rhs: TickDuration)

Performs the += operation. Read more
source§

impl AddAssign for TickDuration

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl Clone for TickDuration

source§

fn clone(&self) -> TickDuration

Returns a copy 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 TickDuration

source§

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

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

impl Default for TickDuration

source§

fn default() -> TickDuration

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

impl<'de> Deserialize<'de> for TickDuration

source§

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

source§

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

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

impl From<TickDuration> for i64

source§

fn from(value: TickDuration) -> Self

Converts to this type from the input type.
source§

impl Hash for TickDuration

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Neg for TickDuration

source§

type Output = TickDuration

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Ord for TickDuration

source§

fn cmp(&self, other: &TickDuration) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for TickDuration

source§

fn eq(&self, other: &TickDuration) -> 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 PartialOrd for TickDuration

source§

fn partial_cmp(&self, other: &TickDuration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for TickDuration

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<TickDuration> for TickInstant

source§

type Output = TickInstant

The resulting type after applying the - operator.
source§

fn sub(self, rhs: TickDuration) -> Self::Output

Performs the - operation. Read more
source§

impl Sub for TickDuration

source§

type Output = TickDuration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign<TickDuration> for TickInstant

source§

fn sub_assign(&mut self, rhs: TickDuration)

Performs the -= operation. Read more
source§

impl SubAssign for TickDuration

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl Copy for TickDuration

source§

impl Eq for TickDuration

source§

impl StructuralPartialEq for TickDuration

Auto Trait Implementations§

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, dst: *mut T)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,