pub struct TimeBase {
pub numer: u32,
pub denom: u32,
}Expand description
A TimeBase is the conversion factor between time, expressed in seconds, and a TimeStamp or
Duration.
In other words, a TimeBase is the length in seconds of one tick of a TimeStamp or
Duration.
Fields§
§numer: u32The numerator.
denom: u32The denominator.
Implementations§
Source§impl TimeBase
impl TimeBase
Sourcepub fn new(numer: u32, denom: u32) -> Self
pub fn new(numer: u32, denom: u32) -> Self
Creates a new TimeBase. Panics if either the numerator or denominator is 0.
Sourcepub fn calc_time(&self, ts: TimeStamp) -> Time
pub fn calc_time(&self, ts: TimeStamp) -> Time
Accurately calculates a Time using the TimeBase and the provided TimeStamp. On
overflow, the seconds field of Time wraps.
Sourcepub fn calc_timestamp(&self, time: Time) -> TimeStamp
pub fn calc_timestamp(&self, time: Time) -> TimeStamp
Accurately calculates a TimeStamp from the given Time using the TimeBase as the
conversion factor. On overflow, the TimeStamp wraps.
Trait Implementations§
Source§impl Ord for TimeBase
impl Ord for TimeBase
Source§impl PartialOrd for TimeBase
impl PartialOrd for TimeBase
impl Copy for TimeBase
impl Eq for TimeBase
impl StructuralPartialEq for TimeBase
Auto Trait Implementations§
impl Freeze for TimeBase
impl RefUnwindSafe for TimeBase
impl Send for TimeBase
impl Sync for TimeBase
impl Unpin for TimeBase
impl UnwindSafe for TimeBase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more