Struct TimeDiff

Source
pub struct TimeDiff(/* private fields */);
Expand description

A time difference between two timestamps.

Implementations§

Source§

impl TimeDiff

Source

pub fn millis(&self) -> u64

Returns the time difference as the number of milliseconds since the Unix epoch

Source

pub const fn from_seconds(seconds: u32) -> Self

Creates a new time difference from seconds.

Source

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

Creates a new time difference from milliseconds.

Source

pub fn saturating_add(self, rhs: u64) -> Self

Returns the sum, or TimeDiff(u64::MAX) if it would overflow.

Source

pub fn saturating_mul(self, rhs: u64) -> Self

Returns the product, or TimeDiff(u64::MAX) if it would overflow.

Source

pub fn checked_mul(self, rhs: u64) -> Option<Self>

Returns the product, or None if it would overflow.

Trait Implementations§

Source§

impl Add<TimeDiff> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the + operator.
Source§

fn add(self, diff: TimeDiff) -> Timestamp

Performs the + operation. Read more
Source§

impl Add for TimeDiff

Source§

type Output = TimeDiff

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<TimeDiff> for Timestamp

Source§

fn add_assign(&mut self, rhs: TimeDiff)

Performs the += operation. Read more
Source§

impl AddAssign for TimeDiff

Source§

fn add_assign(&mut self, rhs: TimeDiff)

Performs the += operation. Read more
Source§

impl Clone for TimeDiff

Source§

fn clone(&self) -> TimeDiff

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 TimeDiff

Source§

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

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

impl Default for TimeDiff

Source§

fn default() -> TimeDiff

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

impl Div<u64> for TimeDiff

Source§

type Output = TimeDiff

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> TimeDiff

Performs the / operation. Read more
Source§

impl Div for TimeDiff

Source§

type Output = u64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: TimeDiff) -> u64

Performs the / operation. Read more
Source§

impl From<Duration> for TimeDiff

Source§

fn from(duration: Duration) -> TimeDiff

Converts to this type from the input type.
Source§

impl From<TimeDiff> for Duration

Source§

fn from(diff: TimeDiff) -> Duration

Converts to this type from the input type.
Source§

impl FromBytes for TimeDiff

Source§

fn from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

Deserializes the slice into Self.
Source§

fn from_vec(bytes: Vec<u8>) -> Result<(Self, Vec<u8>), Error>

Deserializes the Vec<u8> into Self.
Source§

impl Hash for TimeDiff

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 Mul<u64> for TimeDiff

Source§

type Output = TimeDiff

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> TimeDiff

Performs the * operation. Read more
Source§

impl Ord for TimeDiff

Source§

fn cmp(&self, other: &TimeDiff) -> 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,

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

impl PartialEq for TimeDiff

Source§

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

Source§

fn partial_cmp(&self, other: &TimeDiff) -> 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 Rem<TimeDiff> for Timestamp

Source§

type Output = TimeDiff

The resulting type after applying the % operator.
Source§

fn rem(self, diff: TimeDiff) -> TimeDiff

Performs the % operation. Read more
Source§

impl Sub for TimeDiff

Source§

type Output = TimeDiff

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: TimeDiff) -> TimeDiff

Performs the - operation. Read more
Source§

impl SubAssign for TimeDiff

Source§

fn sub_assign(&mut self, rhs: TimeDiff)

Performs the -= operation. Read more
Source§

impl ToBytes for TimeDiff

Source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes &self to a Vec<u8>.
Source§

fn serialized_length(&self) -> usize

Returns the length of the Vec<u8> which would be returned from a successful call to to_bytes() or into_bytes(). The data is not actually serialized, so this call is relatively cheap.
Source§

fn into_bytes(self) -> Result<Vec<u8>, Error>
where Self: Sized,

Consumes self and serializes to a Vec<u8>.
Source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Writes &self into a mutable writer.
Source§

impl Copy for TimeDiff

Source§

impl Eq for TimeDiff

Source§

impl StructuralPartialEq for TimeDiff

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, 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, 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> Same for T

Source§

type Output = T

Should always be Self
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, 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, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,