Skip to main content

Delta

Struct Delta 

Source
pub struct Delta<U: TimeUnit = Nsec> { /* private fields */ }
Expand description

A span of time.

The span is stored in the unit given by the type parameter U (see TimeUnit); its value has type U::Repr. U defaults to Nsec, so a plain Delta is a span in nanoseconds. The value can be negative, zero, or positive.

Implementations§

Source§

impl Delta<Jiffy>

Source

pub const fn from_jiffies(jiffies: isize) -> Self

Create a new Delta from a number of jiffies.

Source

pub const fn as_jiffies(self) -> isize

Return the number of jiffies in the Delta.

Source§

impl Delta

Source

pub const ZERO: Self

A span of time equal to zero.

Source

pub const fn from_nanos(nanos: i64) -> Self

Create a new Delta from a number of nanoseconds.

Source

pub const fn from_micros(micros: i64) -> Self

Create a new Delta from a number of microseconds.

The micros can range from -9_223_372_036_854_775 to 9_223_372_036_854_775. If micros is outside this range, i64::MIN is used for negative values, and i64::MAX is used for positive values due to saturation.

Source

pub const fn from_millis(millis: i64) -> Self

Create a new Delta from a number of milliseconds.

The millis can range from -9_223_372_036_854 to 9_223_372_036_854. If millis is outside this range, i64::MIN is used for negative values, and i64::MAX is used for positive values due to saturation.

Source

pub const fn from_secs(secs: i64) -> Self

Create a new Delta from a number of seconds.

The secs can range from -9_223_372_036 to 9_223_372_036. If secs is outside this range, i64::MIN is used for negative values, and i64::MAX is used for positive values due to saturation.

Source

pub fn is_zero(self) -> bool

Return true if the Delta spans no time.

Source

pub fn is_negative(self) -> bool

Return true if the Delta spans a negative amount of time.

Source

pub const fn as_nanos(self) -> i64

Return the number of nanoseconds in the Delta.

Source

pub fn as_micros_ceil(self) -> i64

Return the smallest number of microseconds greater than or equal to the value in the Delta.

Source

pub fn as_millis(self) -> i64

Return the number of milliseconds in the Delta.

Source

pub fn as_millis_ceil(self) -> i64

Return the smallest number of milliseconds greater than or equal to the value in the Delta.

Source

pub fn rem_nanos(self, dividend: i32) -> Self

Return self % dividend where dividend is in nanoseconds.

The kernel doesn’t have any emulation for s64 % s64 on 32 bit platforms, so this is limited to 32 bit dividends.

Trait Implementations§

Source§

impl Add for Delta

Source§

type Output = Delta

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: ClockSource> Add<Delta> for Instant<T>

Source§

type Output = Instant<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Delta

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<U: Clone + TimeUnit> Clone for Delta<U>
where U::Repr: Clone,

Source§

fn clone(&self) -> Delta<U>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<U: Copy + TimeUnit> Copy for Delta<U>
where U::Repr: Copy,

Source§

impl<U: Debug + TimeUnit> Debug for Delta<U>
where U::Repr: Debug,

Source§

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

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

impl Div for Delta

Source§

type Output = i64

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<U: Eq + TimeUnit> Eq for Delta<U>
where U::Repr: Eq,

Source§

impl HrTimerExpires for Delta

Source§

fn as_nanos(&self) -> i64

Converts the expiration time into a nanosecond representation. Read more
Source§

impl Mul<i64> for Delta

Source§

type Output = Delta

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<i64> for Delta

Source§

fn mul_assign(&mut self, rhs: i64)

Performs the *= operation. Read more
Source§

impl<U: Ord + TimeUnit> Ord for Delta<U>
where U::Repr: Ord,

Source§

fn cmp(&self, other: &Delta<U>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<U: PartialEq + TimeUnit> PartialEq for Delta<U>
where U::Repr: PartialEq,

Source§

fn eq(&self, other: &Delta<U>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<U: PartialOrd + TimeUnit> PartialOrd for Delta<U>
where U::Repr: PartialOrd,

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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<U: PartialEq + TimeUnit> StructuralPartialEq for Delta<U>
where U::Repr: PartialEq,

Source§

impl Sub for Delta

Source§

type Output = Delta

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: ClockSource> Sub<Delta> for Instant<T>

Source§

type Output = Instant<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Delta

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<U> Freeze for Delta<U>
where <U as TimeUnit>::Repr: Freeze,

§

impl<U> RefUnwindSafe for Delta<U>
where <U as TimeUnit>::Repr: RefUnwindSafe,

§

impl<U> Send for Delta<U>
where <U as TimeUnit>::Repr: Send,

§

impl<U> Sync for Delta<U>
where <U as TimeUnit>::Repr: Sync,

§

impl<U> Unpin for Delta<U>
where <U as TimeUnit>::Repr: Unpin,

§

impl<U> UnsafeUnpin for Delta<U>
where <U as TimeUnit>::Repr: UnsafeUnpin,

§

impl<U> UnwindSafe for Delta<U>
where <U as TimeUnit>::Repr: UnwindSafe,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Init<T> for T

Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. 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<S, T> IntoSafeCast<T> for S
where T: FromSafeCast<S>,

Source§

fn into_safe_cast(self) -> T

Convert self into a T. This operation is guaranteed to be lossless.
Source§

impl<S, T> IntoSafeCastArch<T> for S
where T: FromSafeCastArch<S>,

Source§

fn into_safe_cast_arch(self) -> T

Convert self into a T. This operation is guaranteed to be lossless.
Source§

impl<T> KnownSize for T

Source§

const MIN_SIZE: usize = const MIN_SIZE: usize = size_of::<T>();

Minimum size of this type known at compile-time.
Source§

const MIN_ALIGN: Alignment = const MIN_ALIGN: Alignment = Alignment::of::<T>();

Minimum alignment of this type known at compile-time.
Source§

fn size(_: *const T) -> usize

Get the size of an object of this type in bytes, with the metadata of the given pointer.
Source§

impl<T> PinInit<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T, U, const N: u32> TryIntoBounded<T, N> for U
where T: Integer, U: TryInto<T>,

Source§

fn try_into_bounded(self) -> Option<Bounded<T, N>>

Attempts to convert self into a Bounded using N bits. Read more
Source§

impl<T> Writer for T
where T: Debug,

Source§

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

Formats the value using the given formatter.