[−][src]Enum kekbit_core::tick::TickUnit
A TickUnit represents a specific time duration but does not maintain time information, it only helps define the time granularity required to used in various contexts by all kekbit components which share a given channel. For each channel it's TickUnit will be spcified at creation and will never be changed
Variants
TickUnit representing one thousandth of a microsecond.
TickUnit representing one thousandth of a millisecond.
TickUnit representing one thousandth of a second.
TickUnit representing one second.
Methods
impl TickUnit
[src]
pub fn id(self) -> u8
[src]
Returns the unique u8 id assigned to every TickUnit. This id it's used for serialization it would never change.
Examples
use kekbit_core::tick::TickUnit::*; assert_eq!(Nanos.id(), 9); assert_eq!(Micros.id(), 6); assert_eq!(Millis.id(), 3); assert_eq!(Secs.id(), 0);
pub fn from_id(id: u8) -> TickUnit
[src]
Returns the tick unit with the given id
Arguments
id
- The identifier of the tick unit as u8. In the curent kekbit version it must be 0, 3, 6 or 9
Panics
If the specified id has no tick unit attached
pub fn convert(self, duration: Duration) -> u64
[src]
Returns the total number of tick units contained by this Duration
as a u64.
If the tiemstamp size is longer than 64 bits, it will be truncated to the lower 64 bits
Examples
use std::time::Duration; use kekbit_core::tick::TickUnit::*; let duration = Duration::new(1, 500_000_000); //1 sec and a half assert_eq!(Nanos.convert(duration), 1_500_000_000); assert_eq!(Micros.convert(duration), 1_500_000); assert_eq!(Millis.convert(duration), 1_500); assert_eq!(Secs.convert(duration), 1);
pub fn nix_time(self) -> u64
[src]
Returns the difference, measured in the current tick unit, between the current time and midnight, January 1, 1970 UTC.
Examples
use kekbit_core::tick::TickUnit::*; println!("{}ms since January 1, 1970 UTC", Millis.nix_time());
Trait Implementations
impl Clone for TickUnit
[src]
impl Copy for TickUnit
[src]
impl Debug for TickUnit
[src]
impl Eq for TickUnit
[src]
impl PartialEq<TickUnit> for TickUnit
[src]
impl StructuralEq for TickUnit
[src]
impl StructuralPartialEq for TickUnit
[src]
Auto Trait Implementations
impl RefUnwindSafe for TickUnit
impl Send for TickUnit
impl Sync for TickUnit
impl Unpin for TickUnit
impl UnwindSafe for TickUnit
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,