Enum Resolution

Source
pub enum Resolution {
Show 19 variants Day, AmPm, TimeOfDay, ThreeHour, Hour, ThirtyMinute, FifteenMinute, FiveMinute, Minute, ThirtySecond, FifteenSecond, FiveSecond, Second, FiveHundredMilli, HundredMilli, FiftyMilli, TenMilli, FiveMilli, Millisecond,
}
Expand description

There are 19 resolutions available:

  • milli, 5ms, 10ms, 50ms, 100ms, 500ms
  • second, 5s, 15s, 30s
  • minute, 5m, 15m, 30m
  • hour, 3h, 6h, 12h (am/pm)
  • whole day

The Ord impl follows natural-language: x < y means that x is lower-resolution than y.

§How were these chosen?

The rule is that, for any pair of resolutions, one must be an exact integer multiple of the other. So this means, for example that “10m” and “15m” are incompatible resolutions. You can choose to allow one, or the other, but not both. (I picked 15m.)

FYI you can see this integer multiple by dividing one resolution by another:

assert_eq!(Resolution::ThirtySecond / Resolution::FiftyMilli, 600);

Variants§

§

Day

§

AmPm

§

TimeOfDay

§

ThreeHour

§

Hour

§

ThirtyMinute

§

FifteenMinute

§

FiveMinute

§

Minute

§

ThirtySecond

§

FifteenSecond

§

FiveSecond

§

Second

§

FiveHundredMilli

§

HundredMilli

§

FiftyMilli

§

TenMilli

§

FiveMilli

§

Millisecond

Implementations§

Source§

impl Resolution

Source

pub const fn width(self) -> Duration

Source§

impl Resolution

Source

pub fn coarser(self) -> Option<Self>

Source

pub fn finer(self) -> Option<Self>

Trait Implementations§

Source§

impl Clone for Resolution

Source§

fn clone(&self) -> Resolution

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 Resolution

Source§

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

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

impl Display for Resolution

Source§

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

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

impl Div for Resolution

Source§

type Output = u32

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl From<Resolution> for Duration

Source§

fn from(value: Resolution) -> Self

Converts to this type from the input type.
Source§

impl Linearize for Resolution

Source§

const LENGTH: usize = 19usize

The cardinality of this type.
Source§

type Storage<__T> = [__T; 19]

[T; Self::LENGTH] Read more
Source§

type CopyStorage<__T> = [__T; 19] where __T: Copy

[T; Self::LENGTH] Read more
Source§

fn linearize(&self) -> usize

Maps this value to the natural numbers. Read more
Source§

unsafe fn from_linear_unchecked(linear: usize) -> Self

The inverse of the linearize function. Read more
Source§

impl Ord for Resolution

Source§

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

Source§

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

Source§

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

Source§

impl Eq for Resolution

Source§

impl StructuralPartialEq for Resolution

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

Source§

fn from_linear(linear: usize) -> Option<T>

Source§

fn variants() -> Variants<T>

Returns an iterator over all values of this type.
Source§

fn linearized(&self) -> Linearized<T>

Linearizes this value and stores the value in a Linearized object. 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§

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.