Struct readable::time::TimeUnit

source ·
pub struct TimeUnit { /* private fields */ }
Expand description

Unit of time

Unlike most readable types, this struct is not a string; it is a utility type that takes seconds as input and calculates the different units of time from it.

For example:

assert_eq!(TimeUnit::from(1).seconds(), 1);
assert_eq!(TimeUnit::from(60).minutes(), 1);
assert_eq!(TimeUnit::from(3600).hours(), 1);
assert_eq!(TimeUnit::from(86400).days(), 1);
assert_eq!(TimeUnit::from(86400 * 7).weeks(), 1);
assert_eq!(TimeUnit::from(86400 * 31).months(), 1);
assert_eq!(TimeUnit::from(86400 * 365).years(), 1);

If a unit overflows it will carry over to the lower unit, for example:

let unit = TimeUnit::from(
	31536000 + // 1 year
	5356800  + // 2 months
	1814400  + // 3 weeks
	345600   + // 4 days
	18000    + // 5 hours
    360      + // 6 minutes
    7          // 7 seconds
);

assert_eq!(unit.years(),   1);
assert_eq!(unit.months(),  2);
assert_eq!(unit.weeks(),   3);
assert_eq!(unit.days(),    4);
assert_eq!(unit.hours(),   5);
assert_eq!(unit.minutes(), 6);
assert_eq!(unit.seconds(), 7);

// Total amount of seconds.
assert_eq!(unit.inner(), 39071167);

Size

assert_eq!(std::mem::size_of::<TimeUnit>(), 12);

Uptime & Conversion

Like the other readable::time types, TimeUnit implements Uptime and can be losslessly convert from/into other readable::time types, even maintaining unknown variants:

// Uptime
let time = Uptime::from(86461);
assert_eq!(time, "1d, 1m, 1s");

// TimeUnit
let unit = TimeUnit::from(time);
assert_eq!(unit.inner(),   86461);
assert_eq!(unit.years(),   0);
assert_eq!(unit.months(),  0);
assert_eq!(unit.weeks(),   0);
assert_eq!(unit.days(),    1);
assert_eq!(unit.hours(),   0);
assert_eq!(unit.minutes(), 1);
assert_eq!(unit.seconds(), 1);

// Maintain the `unknown` variant.
let time: Uptime     = Uptime::unknown();
let unit: TimeUnit = TimeUnit::from(time);
assert!(unit.is_unknown());
let time: Uptime = Uptime::from(unit);
assert!(time.is_unknown());

Naive time

Like the othear readable::time types, TimeUnit naively assumes that:

  1. Each day is 86400 seconds
  2. Each month is 31 days
  3. Each year is 365 days

This is incorrect as not all months are 31 days long and leap years exist.

Implementations§

source§

impl TimeUnit

source

pub const UNKNOWN: Self = _

assert_eq!(TimeUnit::UNKNOWN.inner(),   0);
assert_eq!(TimeUnit::UNKNOWN.years(),   0);
assert_eq!(TimeUnit::UNKNOWN.months(),  0);
assert_eq!(TimeUnit::UNKNOWN.weeks(),   0);
assert_eq!(TimeUnit::UNKNOWN.days(),    0);
assert_eq!(TimeUnit::UNKNOWN.hours(),   0);
assert_eq!(TimeUnit::UNKNOWN.minutes(), 0);
assert_eq!(TimeUnit::UNKNOWN.seconds(), 0);
assert_eq!(TimeUnit::UNKNOWN, TimeUnit::from(-1));
assert_eq!(TimeUnit::UNKNOWN, TimeUnit::from(u64::MAX));
assert_eq!(TimeUnit::UNKNOWN, TimeUnit::from(f32::NAN));
assert!(TimeUnit::UNKNOWN.is_unknown());
source

pub const ZERO: Self = _

assert_eq!(TimeUnit::ZERO.inner(), 0);
assert_eq!(TimeUnit::ZERO, TimeUnit::from(0));
source

pub const SECOND: Self = _

assert_eq!(TimeUnit::SECOND.inner(), 1);
assert_eq!(TimeUnit::SECOND.seconds(), 1);
assert_eq!(TimeUnit::SECOND, TimeUnit::from(1));
source

pub const MINUTE: Self = _

assert_eq!(TimeUnit::MINUTE.inner(), 60);
assert_eq!(TimeUnit::MINUTE.minutes(), 1);
assert_eq!(TimeUnit::MINUTE, TimeUnit::from(60));
source

pub const HOUR: Self = _

assert_eq!(TimeUnit::HOUR.inner(), 3600);
assert_eq!(TimeUnit::HOUR.hours(), 1);
assert_eq!(TimeUnit::HOUR, TimeUnit::from(3600));
source

pub const DAY: Self = _

assert_eq!(TimeUnit::DAY.inner(), 86400);
assert_eq!(TimeUnit::DAY.days(), 1);
assert_eq!(TimeUnit::DAY, TimeUnit::from(86400));
source

pub const WEEK: Self = _

assert_eq!(TimeUnit::WEEK.inner(), 604800);
assert_eq!(TimeUnit::WEEK.weeks(), 1);
assert_eq!(TimeUnit::WEEK, TimeUnit::from(604800));
source

pub const MONTH: Self = _

assert_eq!(TimeUnit::MONTH.inner(), 2678400);
assert_eq!(TimeUnit::MONTH.months(), 1);
assert_eq!(TimeUnit::MONTH, TimeUnit::from(2678400));
source

pub const YEAR: Self = _

assert_eq!(TimeUnit::YEAR.inner(), 31536000);
assert_eq!(TimeUnit::YEAR.years(), 1);
assert_eq!(TimeUnit::YEAR, TimeUnit::from(31536000));
source

pub const MAX: Self = _

assert_eq!(TimeUnit::MAX.inner(),   u32::MAX);
assert_eq!(TimeUnit::MAX.years(),   136);
assert_eq!(TimeUnit::MAX.months(),  2);
assert_eq!(TimeUnit::MAX.weeks(),   1);
assert_eq!(TimeUnit::MAX.days(),    1);
assert_eq!(TimeUnit::MAX.hours(),   6);
assert_eq!(TimeUnit::MAX.minutes(), 28);
assert_eq!(TimeUnit::MAX.seconds(), 15);
assert_eq!(TimeUnit::MAX, TimeUnit::from(u32::MAX));
source§

impl TimeUnit

source

pub const fn unknown() -> Self

assert_eq!(TimeUnit::unknown(), TimeUnit::UNKNOWN);
source

pub const fn zero() -> Self

assert_eq!(TimeUnit::zero(), TimeUnit::ZERO);
source

pub const fn second() -> Self

assert_eq!(TimeUnit::second(), TimeUnit::SECOND);
source

pub const fn minute() -> Self

assert_eq!(TimeUnit::minute(), TimeUnit::MINUTE);
source

pub const fn hour() -> Self

assert_eq!(TimeUnit::hour(), TimeUnit::HOUR);
source

pub const fn day() -> Self

assert_eq!(TimeUnit::day(), TimeUnit::DAY);
source

pub const fn week() -> Self

assert_eq!(TimeUnit::week(), TimeUnit::WEEK);
source

pub const fn month() -> Self

assert_eq!(TimeUnit::month(), TimeUnit::MONTH);
source

pub const fn year() -> Self

assert_eq!(TimeUnit::year(), TimeUnit::YEAR);
source

pub const fn max() -> Self

assert_eq!(TimeUnit::max(), TimeUnit::MAX);
source§

impl TimeUnit

source

pub const fn new(secs: u32) -> Self

Create a new TimeUnit from seconds as input.

This will divide and use the remainder to calculate each unit, for example 62 as input would lead to 1 minute and 2 seconds.

let unit = TimeUnit::from(62);
assert_eq!(unit.minutes(), 1);
assert_eq!(unit.seconds(), 2);
source

pub const fn from_minutes(minutes: u32) -> Self

Create Self with minutes as input

let unit = TimeUnit::from_minutes(1);
assert_eq!(unit.inner(), 60);
Maximum Input

The maximum input is 71_582_788 minutes before this function saturates.

source

pub const fn from_hours(hours: u32) -> Self

Create Self with hours as input

let unit = TimeUnit::from_hours(1);
assert_eq!(unit.inner(), 3_600);
Maximum Input

The maximum input is 1_193_046 hours before this function saturates.

source

pub const fn from_days(days: u16) -> Self

Create Self with days as input

let unit = TimeUnit::from_days(1);
assert_eq!(unit.inner(), 86_400);
Maximum Input

The maximum input is 49_710 days before this function saturates.

source

pub const fn from_weeks(weeks: u16) -> Self

Create Self with weeks as input

let unit = TimeUnit::from_weeks(1);
assert_eq!(unit.inner(), 604_800);
Maximum Input

The maximum input is 7_101 weeks before this function saturates.

source

pub const fn from_months(months: u16) -> Self

Create Self with months as input

let unit = TimeUnit::from_months(1);
assert_eq!(unit.inner(), 2_678_400);
Maximum Input

The maximum input is 1_603 months before this function saturates.

source

pub const fn from_years(years: u8) -> Self

Create Self with years as input

let unit = TimeUnit::from_years(1);
assert_eq!(unit.inner(), 31_536_000);
Maximum Input

The maximum input is 136 years before this function saturates.

source

pub const fn new_variety( years: u8, months: u16, weeks: u16, days: u16, hours: u32, minutes: u32, seconds: u32 ) -> Self

Create a new TimeUnit from a variety of input

This multiplies and combines all the input.

Maximum Input

If the total second count of all the inputs combined exceeds u32::MAX then this function will saturate and return TimeUnit::MAX.

Examples
let unit = TimeUnit::new_variety(
	0, // years   (0s)
	1, // months  (2678400s)
	2, // weeks   (1209600s)
	3, // days    (259200s)
	4, // hours   (14400s)
	5, // minutes (300s)
	6, // seconds (6s)
);

// Total second count: 4,161,906 seconds
assert_eq!(unit.inner(), 4_161_906);
assert_eq!(unit.years(),   0);
assert_eq!(unit.months(),  1);
assert_eq!(unit.weeks(),   2);
assert_eq!(unit.days(),    3);
assert_eq!(unit.hours(),   4);
assert_eq!(unit.minutes(), 5);
assert_eq!(unit.seconds(), 6);

Example of saturating inputs.

let unit = TimeUnit::new_variety(
	172,   // years
	134,   // months
	22,    // weeks
	32575, // days
	46,    // hours
	5123,  // minutes
	54,    // seconds
);

assert_eq!(unit, TimeUnit::MAX);
source

pub const fn into_raw(self) -> (bool, u32, u8, u8, u8, u8, u8, u8, u8)

Returns the internal structure.

A tuple is returned mirroring the internal structure of TimeUnit, going from left-to-right:

Example
let (
	unknown,
	inner,
	years,
	months,
	weeks,
	days,
	hours,
	minutes,
	seconds,
) = TimeUnit::from(39071167).into_raw();

assert_eq!(unknown, false);
assert_eq!(inner,   39071167);
assert_eq!(years,   1);
assert_eq!(months,  2);
assert_eq!(weeks,   3);
assert_eq!(days,    4);
assert_eq!(hours,   5);
assert_eq!(minutes, 6);
assert_eq!(seconds, 7);
source

pub const fn to_raw(&self) -> (bool, u32, u8, u8, u8, u8, u8, u8, u8)

Same as TimeUnit::into_raw() but does not destruct self

source

pub const fn is_unknown(&self) -> bool

An unknown TimeUnit can be created on irregular input (negative integer, NaN float, etc) or if it was converted from a different readable::time type that was unknown.

This function checks if self is unknown.

Although all inner numbers are all set to 0, a flag is set internally such that:

assert!(TimeUnit::zero() != TimeUnit::unknown());
Examples
assert!(TimeUnit::UNKNOWN.is_unknown());
assert!(TimeUnit::from(Uptime::UNKNOWN).is_unknown());
assert!(TimeUnit::from(f32::NAN).is_unknown());
assert!(TimeUnit::from(-1).is_unknown());
source

pub const fn inner(&self) -> u32

Returns the total amount of seconds this TimeUnit represents.

let unit = TimeUnit::from(123);

assert_eq!(unit.minutes(), 2);
assert_eq!(unit.seconds(), 3);
assert_eq!(unit.inner(), 123);
source

pub const fn years(&self) -> u8

Returns the remaining amount of years this TimeUnit represents.

assert_eq!(TimeUnit::from(86400 * 364).years(), 0);
assert_eq!(TimeUnit::from(86400 * 365).years(), 1);
source

pub const fn months(&self) -> u8

Returns the remaining amount of months this TimeUnit represents.

assert_eq!(TimeUnit::from(86400 * 30).months(), 0);
assert_eq!(TimeUnit::from(86400 * 31).months(), 1);
source

pub const fn weeks(&self) -> u8

Returns the remaining amount of weeks this TimeUnit represents.

assert_eq!(TimeUnit::from(86400 * 6).weeks(), 0);
assert_eq!(TimeUnit::from(86400 * 7).weeks(), 1);
source

pub const fn days(&self) -> u8

Returns the remaining amount of days this TimeUnit represents.

assert_eq!(TimeUnit::from(86399).days(), 0);
assert_eq!(TimeUnit::from(86400).days(), 1);
source

pub const fn hours(&self) -> u8

Returns the remaining amount of hours this TimeUnit represents.

assert_eq!(TimeUnit::from(3599).hours(), 0);
assert_eq!(TimeUnit::from(3600).hours(), 1);
source

pub const fn minutes(&self) -> u8

Returns the remaining amount of minutes this TimeUnit represents.

assert_eq!(TimeUnit::from(59).minutes(), 0);
assert_eq!(TimeUnit::from(60).minutes(), 1);
source

pub const fn seconds(&self) -> u8

Returns the remaining amount of seconds this TimeUnit represents.

This is the remaining amount of seconds, not the total amount of seconds.

// `0` is returned since `60` is == `1 minute`.
assert_eq!(TimeUnit::from(60).seconds(), 0);
assert_eq!(TimeUnit::from(60).minutes(), 1);
assert_eq!(TimeUnit::from(60).inner(), 60);

// `1` is returned since there's 1 remaining second.
assert_eq!(TimeUnit::from(61).seconds(), 1);
assert_eq!(TimeUnit::from(61).minutes(), 1);
assert_eq!(TimeUnit::from(61).inner(),   61);

Trait Implementations§

source§

impl Add<&TimeUnit> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the + operator.
source§

fn add(self, other: &TimeUnit) -> Self

Performs the + operation. Read more
source§

impl Add<&TimeUnit> for u32

§

type Output = u32

The resulting type after applying the + operator.
source§

fn add(self, other: &TimeUnit) -> Self

Performs the + operation. Read more
source§

impl Add<&u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the + operator.
source§

fn add(self, other: &u32) -> Self

Performs the + operation. Read more
source§

impl Add<TimeUnit> for u32

§

type Output = u32

The resulting type after applying the + operator.
source§

fn add(self, other: TimeUnit) -> Self

Performs the + operation. Read more
source§

impl Add<u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the + operator.
source§

fn add(self, other: u32) -> Self

Performs the + operation. Read more
source§

impl Add for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the + operator.
source§

fn add(self, other: TimeUnit) -> Self

Performs the + operation. Read more
source§

impl<'__de> BorrowDecode<'__de> for TimeUnit

source§

fn borrow_decode<__D: BorrowDecoder<'__de>>( decoder: &mut __D ) -> Result<Self, DecodeError>

Attempt to decode this type with the given BorrowDecode.
source§

impl Clone for TimeUnit

source§

fn clone(&self) -> TimeUnit

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 TimeUnit

source§

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

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

impl Decode for TimeUnit

source§

fn decode<__D: Decoder>(decoder: &mut __D) -> Result<Self, DecodeError>

Attempt to decode this type with the given Decode.
source§

impl Default for TimeUnit

source§

fn default() -> Self

Calls Self::zero

source§

impl<'de> Deserialize<'de> for TimeUnit

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 Div<&TimeUnit> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the / operator.
source§

fn div(self, other: &TimeUnit) -> Self

Performs the / operation. Read more
source§

impl Div<&TimeUnit> for u32

§

type Output = u32

The resulting type after applying the / operator.
source§

fn div(self, other: &TimeUnit) -> Self

Performs the / operation. Read more
source§

impl Div<&u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the / operator.
source§

fn div(self, other: &u32) -> Self

Performs the / operation. Read more
source§

impl Div<TimeUnit> for u32

§

type Output = u32

The resulting type after applying the / operator.
source§

fn div(self, other: TimeUnit) -> Self

Performs the / operation. Read more
source§

impl Div<u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the / operator.
source§

fn div(self, other: u32) -> Self

Performs the / operation. Read more
source§

impl Div for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the / operator.
source§

fn div(self, other: TimeUnit) -> Self

Performs the / operation. Read more
source§

impl Encode for TimeUnit

source§

fn encode<__E: Encoder>(&self, encoder: &mut __E) -> Result<(), EncodeError>

Encode a given type.
source§

impl From<&Duration> for TimeUnit

source§

fn from(duration: &Duration) -> Self

Converts to this type from the input type.
source§

impl From<&Htop> for TimeUnit

source§

fn from(from: &Htop) -> Self

Converts to this type from the input type.
source§

impl From<&Instant> for TimeUnit

source§

fn from(instant: &Instant) -> Self

Converts to this type from the input type.
source§

impl From<&Military> for TimeUnit

source§

fn from(from: &Military) -> Self

Converts to this type from the input type.
source§

impl From<&Time> for TimeUnit

source§

fn from(from: &Time) -> Self

Converts to this type from the input type.
source§

impl From<&TimeUnit> for Duration

source§

fn from(value: &TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<&TimeUnit> for Htop

source§

fn from(from: &TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<&TimeUnit> for Military

source§

fn from(other: &TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<&TimeUnit> for Time

source§

fn from(other: &TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<&TimeUnit> for Uptime

source§

fn from(from: &TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<&TimeUnit> for UptimeFull

source§

fn from(from: &TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<&Unsigned> for TimeUnit

source§

fn from(from: &Unsigned) -> Self

Converts to this type from the input type.
source§

impl From<&Uptime> for TimeUnit

source§

fn from(from: &Uptime) -> Self

Converts to this type from the input type.
source§

impl From<&UptimeFull> for TimeUnit

source§

fn from(from: &UptimeFull) -> Self

Converts to this type from the input type.
source§

impl From<&f32> for TimeUnit

source§

fn from(float: &f32) -> Self

Converts to this type from the input type.
source§

impl From<&f64> for TimeUnit

source§

fn from(float: &f64) -> Self

Converts to this type from the input type.
source§

impl From<&i128> for TimeUnit

source§

fn from(int: &i128) -> Self

Converts to this type from the input type.
source§

impl From<&i16> for TimeUnit

source§

fn from(int: &i16) -> Self

Converts to this type from the input type.
source§

impl From<&i32> for TimeUnit

source§

fn from(int: &i32) -> Self

Converts to this type from the input type.
source§

impl From<&i64> for TimeUnit

source§

fn from(int: &i64) -> Self

Converts to this type from the input type.
source§

impl From<&i8> for TimeUnit

source§

fn from(int: &i8) -> Self

Converts to this type from the input type.
source§

impl From<&isize> for TimeUnit

source§

fn from(u: &isize) -> Self

Converts to this type from the input type.
source§

impl From<&u128> for TimeUnit

source§

fn from(u: &u128) -> Self

Converts to this type from the input type.
source§

impl From<&u16> for TimeUnit

source§

fn from(u: &u16) -> Self

Converts to this type from the input type.
source§

impl From<&u32> for TimeUnit

source§

fn from(u: &u32) -> Self

Converts to this type from the input type.
source§

impl From<&u64> for TimeUnit

source§

fn from(u: &u64) -> Self

Converts to this type from the input type.
source§

impl From<&u8> for TimeUnit

source§

fn from(u: &u8) -> Self

Converts to this type from the input type.
source§

impl From<&usize> for TimeUnit

source§

fn from(u: &usize) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for TimeUnit

source§

fn from(duration: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Htop> for TimeUnit

source§

fn from(from: Htop) -> Self

Converts to this type from the input type.
source§

impl From<Instant> for TimeUnit

source§

fn from(instant: Instant) -> Self

Converts to this type from the input type.
source§

impl From<Military> for TimeUnit

source§

fn from(from: Military) -> Self

Converts to this type from the input type.
source§

impl From<Time> for TimeUnit

source§

fn from(from: Time) -> Self

Converts to this type from the input type.
source§

impl From<TimeUnit> for Duration

source§

fn from(value: TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<TimeUnit> for Htop

source§

fn from(from: TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<TimeUnit> for Military

source§

fn from(other: TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<TimeUnit> for Time

source§

fn from(other: TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<TimeUnit> for Uptime

source§

fn from(from: TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<TimeUnit> for UptimeFull

source§

fn from(from: TimeUnit) -> Self

Converts to this type from the input type.
source§

impl From<Unsigned> for TimeUnit

source§

fn from(from: Unsigned) -> Self

Converts to this type from the input type.
source§

impl From<Uptime> for TimeUnit

source§

fn from(from: Uptime) -> Self

Converts to this type from the input type.
source§

impl From<UptimeFull> for TimeUnit

source§

fn from(from: UptimeFull) -> Self

Converts to this type from the input type.
source§

impl From<f32> for TimeUnit

source§

fn from(float: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for TimeUnit

source§

fn from(float: f64) -> Self

Converts to this type from the input type.
source§

impl From<i128> for TimeUnit

source§

fn from(int: i128) -> Self

Converts to this type from the input type.
source§

impl From<i16> for TimeUnit

source§

fn from(int: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for TimeUnit

source§

fn from(int: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for TimeUnit

source§

fn from(int: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for TimeUnit

source§

fn from(int: i8) -> Self

Converts to this type from the input type.
source§

impl From<isize> for TimeUnit

source§

fn from(u: isize) -> Self

Converts to this type from the input type.
source§

impl From<u128> for TimeUnit

source§

fn from(u: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for TimeUnit

source§

fn from(u: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for TimeUnit

source§

fn from(u: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for TimeUnit

source§

fn from(u: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for TimeUnit

source§

fn from(u: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for TimeUnit

source§

fn from(u: usize) -> Self

Converts to this type from the input type.
source§

impl Hash for TimeUnit

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<&TimeUnit> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the * operator.
source§

fn mul(self, other: &TimeUnit) -> Self

Performs the * operation. Read more
source§

impl Mul<&TimeUnit> for u32

§

type Output = u32

The resulting type after applying the * operator.
source§

fn mul(self, other: &TimeUnit) -> Self

Performs the * operation. Read more
source§

impl Mul<&u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the * operator.
source§

fn mul(self, other: &u32) -> Self

Performs the * operation. Read more
source§

impl Mul<TimeUnit> for u32

§

type Output = u32

The resulting type after applying the * operator.
source§

fn mul(self, other: TimeUnit) -> Self

Performs the * operation. Read more
source§

impl Mul<u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the * operator.
source§

fn mul(self, other: u32) -> Self

Performs the * operation. Read more
source§

impl Mul for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the * operator.
source§

fn mul(self, other: TimeUnit) -> Self

Performs the * operation. Read more
source§

impl Ord for TimeUnit

source§

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

source§

fn eq(&self, other: &TimeUnit) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for TimeUnit

source§

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

This method 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

This method 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

This method 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

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

impl Rem<&TimeUnit> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the % operator.
source§

fn rem(self, other: &TimeUnit) -> Self

Performs the % operation. Read more
source§

impl Rem<&TimeUnit> for u32

§

type Output = u32

The resulting type after applying the % operator.
source§

fn rem(self, other: &TimeUnit) -> Self

Performs the % operation. Read more
source§

impl Rem<&u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the % operator.
source§

fn rem(self, other: &u32) -> Self

Performs the % operation. Read more
source§

impl Rem<TimeUnit> for u32

§

type Output = u32

The resulting type after applying the % operator.
source§

fn rem(self, other: TimeUnit) -> Self

Performs the % operation. Read more
source§

impl Rem<u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the % operator.
source§

fn rem(self, other: u32) -> Self

Performs the % operation. Read more
source§

impl Rem for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the % operator.
source§

fn rem(self, other: TimeUnit) -> Self

Performs the % operation. Read more
source§

impl Serialize for TimeUnit

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<&TimeUnit> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the - operator.
source§

fn sub(self, other: &TimeUnit) -> Self

Performs the - operation. Read more
source§

impl Sub<&TimeUnit> for u32

§

type Output = u32

The resulting type after applying the - operator.
source§

fn sub(self, other: &TimeUnit) -> Self

Performs the - operation. Read more
source§

impl Sub<&u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the - operator.
source§

fn sub(self, other: &u32) -> Self

Performs the - operation. Read more
source§

impl Sub<TimeUnit> for u32

§

type Output = u32

The resulting type after applying the - operator.
source§

fn sub(self, other: TimeUnit) -> Self

Performs the - operation. Read more
source§

impl Sub<u32> for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the - operator.
source§

fn sub(self, other: u32) -> Self

Performs the - operation. Read more
source§

impl Sub for TimeUnit

§

type Output = TimeUnit

The resulting type after applying the - operator.
source§

fn sub(self, other: TimeUnit) -> Self

Performs the - operation. Read more
source§

impl SysTime for TimeUnit

source§

fn sys_time() -> Self

This function creates a Self from the live system date Read more
source§

impl SysUptime for TimeUnit

source§

fn sys_uptime() -> Self

This function creates a Self from the live system uptime and can be used on: Read more
source§

impl Copy for TimeUnit

source§

impl Eq for TimeUnit

source§

impl StructuralEq for TimeUnit

source§

impl StructuralPartialEq for TimeUnit

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> 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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,