#[repr(C)]pub struct JsInstant {
pub ms: js_number,
}js only.Expand description
⬡ 🕘
A high-resolution timestamp based on JavaScript’s performance.now().
📦 size_of::<JsInstant>() == 8 bytes / 64 bits
The internal representation is a double-precision floating-point millisecond value.
Fields§
§ms: js_numberMilliseconds since performance.timeOrigin.
Implementations§
Source§impl JsInstant
impl JsInstant
Sourcepub const fn as_millis_f64(self) -> js_number
pub const fn as_millis_f64(self) -> js_number
Returns the time in milliseconds.
Sourcepub const fn from_millis_f64(millis: js_number) -> Self
pub const fn from_millis_f64(millis: js_number) -> Self
Returns a new JsInstant from a timestamp in milliseconds.
Sourcepub const fn as_secs_f64(self) -> js_number
pub const fn as_secs_f64(self) -> js_number
Returns the time in f64 seconds.
Sourcepub const fn from_secs_f64(secs: js_number) -> Self
pub const fn from_secs_f64(secs: js_number) -> Self
Returns a new JsInstant from a timestamp in milliseconds.
Sourcepub const fn since(self, earlier: Self) -> Self
pub const fn since(self, earlier: Self) -> Self
Returns the duration between this and an earlier JsInstant.
Sourcepub const fn delta_since(self, earlier: Self) -> TimeDelta
pub const fn delta_since(self, earlier: Self) -> TimeDelta
Returns the duration between this and an earlier instant as a TimeDelta.
Source§impl JsInstant
impl JsInstant
Sourcepub fn now() -> Self
Available on crate feature web only.
pub fn now() -> Self
web only.Returns the current instant using performance.now().
Sourcepub fn origin() -> Self
Available on crate feature web only.
pub fn origin() -> Self
web only.Returns the time origin using performance.timeOrigin().
Sourcepub fn reset(&mut self)
Available on crate feature web only.
pub fn reset(&mut self)
web only.Resets this instant to the current time.
Sourcepub fn elapsed(self) -> Self
Available on crate feature web only.
pub fn elapsed(self) -> Self
web only.Returns the elapsed time since this instant.
Sourcepub fn delta_elapsed(self) -> TimeDelta
Available on crate feature web only.
pub fn delta_elapsed(self) -> TimeDelta
web only.Returns the elapsed time since this instant as a TimeDelta.
Trait Implementations§
impl Copy for JsInstant
Source§impl From<EventTimestamp> for JsInstant
impl From<EventTimestamp> for JsInstant
Source§fn from(from: EventTimestamp) -> Self
fn from(from: EventTimestamp) -> Self
Source§impl From<JsInstant> for EventTimestamp
impl From<JsInstant> for EventTimestamp
impl StructuralPartialEq for JsInstant
Source§impl TimeSource<u32> for JsInstant
Available on crate feature web and non-Windows only.Relative u32 projection of JsInstant in milliseconds.
impl TimeSource<u32> for JsInstant
web and non-Windows only.Relative u32 projection of JsInstant in milliseconds.
This compact projection favors storage size while keeping a practical range for browser sessions and medium-lived applications.
At millisecond resolution, u32 spans about 49.7 days.
Source§fn time_is_monotonic() -> bool
fn time_is_monotonic() -> bool
Source§fn time_is_absolute() -> bool
fn time_is_absolute() -> bool
Source§fn time_scale() -> TimeScale
fn time_scale() -> TimeScale
time_point_value
and time_elapsed_value.Source§fn time_point_value(point: u32) -> u64
fn time_point_value(point: u32) -> u64
u64 value in time_scale units.Source§fn time_elapsed_value(elapsed: u32) -> u64
fn time_elapsed_value(elapsed: u32) -> u64
u64 value in time_scale units.Source§fn time_now_millis_f64() -> f64
fn time_now_millis_f64() -> f64
f64.Source§fn time_now_value() -> u64
fn time_now_value() -> u64
u64 value in time_scale units.Source§fn time_elapsed_since(point: P) -> P::Elapsed
fn time_elapsed_since(point: P) -> P::Elapsed
point to now.Source§fn time_elapsed_since_checked(point: P) -> Option<P::Elapsed> ⓘ
fn time_elapsed_since_checked(point: P) -> Option<P::Elapsed> ⓘ
point to now,
or None if it is not valid or not representable.Source§fn time_elapsed_since_value(point: P) -> u64
fn time_elapsed_since_value(point: P) -> u64
Source§fn time_point_seconds(point: P) -> u64
fn time_point_seconds(point: P) -> u64
point to seconds.Source§fn time_point_millis(point: P) -> u64
fn time_point_millis(point: P) -> u64
point to milliseconds.Source§fn time_point_micros(point: P) -> u64
fn time_point_micros(point: P) -> u64
point to microseconds.Source§fn time_point_nanos(point: P) -> u64
fn time_point_nanos(point: P) -> u64
point to nanoseconds.Source§fn time_elapsed_seconds(elapsed: P::Elapsed) -> u64
fn time_elapsed_seconds(elapsed: P::Elapsed) -> u64
elapsed to seconds.Source§fn time_elapsed_millis(elapsed: P::Elapsed) -> u64
fn time_elapsed_millis(elapsed: P::Elapsed) -> u64
elapsed to milliseconds.Source§fn time_elapsed_micros(elapsed: P::Elapsed) -> u64
fn time_elapsed_micros(elapsed: P::Elapsed) -> u64
elapsed to microseconds.Source§fn time_elapsed_nanos(elapsed: P::Elapsed) -> u64
fn time_elapsed_nanos(elapsed: P::Elapsed) -> u64
elapsed to nanoseconds.Source§fn time_now_seconds() -> u64
fn time_now_seconds() -> u64
Source§fn time_now_millis() -> u64
fn time_now_millis() -> u64
Source§fn time_now_micros() -> u64
fn time_now_micros() -> u64
Source§fn time_now_nanos() -> u64
fn time_now_nanos() -> u64
Source§impl TimeSource<u64> for JsInstant
Available on crate feature web and non-Windows only.Relative u64 projection of JsInstant in milliseconds.
impl TimeSource<u64> for JsInstant
web and non-Windows only.Relative u64 projection of JsInstant in milliseconds.
This is the canonical wide numeric projection for the browser high-resolution time origin. Milliseconds are the native scale exposed by the type’s public API.
At millisecond resolution, u64 spans about 584 million years.
Source§fn time_is_monotonic() -> bool
fn time_is_monotonic() -> bool
Source§fn time_is_absolute() -> bool
fn time_is_absolute() -> bool
Source§fn time_scale() -> TimeScale
fn time_scale() -> TimeScale
time_point_value
and time_elapsed_value.Source§fn time_point_value(point: u64) -> u64
fn time_point_value(point: u64) -> u64
u64 value in time_scale units.Source§fn time_elapsed_value(elapsed: u64) -> u64
fn time_elapsed_value(elapsed: u64) -> u64
u64 value in time_scale units.Source§fn time_now_millis_f64() -> f64
fn time_now_millis_f64() -> f64
f64.Source§fn time_now_value() -> u64
fn time_now_value() -> u64
u64 value in time_scale units.Source§fn time_elapsed_since(point: P) -> P::Elapsed
fn time_elapsed_since(point: P) -> P::Elapsed
point to now.Source§fn time_elapsed_since_checked(point: P) -> Option<P::Elapsed> ⓘ
fn time_elapsed_since_checked(point: P) -> Option<P::Elapsed> ⓘ
point to now,
or None if it is not valid or not representable.Source§fn time_elapsed_since_value(point: P) -> u64
fn time_elapsed_since_value(point: P) -> u64
Source§fn time_point_seconds(point: P) -> u64
fn time_point_seconds(point: P) -> u64
point to seconds.Source§fn time_point_millis(point: P) -> u64
fn time_point_millis(point: P) -> u64
point to milliseconds.Source§fn time_point_micros(point: P) -> u64
fn time_point_micros(point: P) -> u64
point to microseconds.Source§fn time_point_nanos(point: P) -> u64
fn time_point_nanos(point: P) -> u64
point to nanoseconds.Source§fn time_elapsed_seconds(elapsed: P::Elapsed) -> u64
fn time_elapsed_seconds(elapsed: P::Elapsed) -> u64
elapsed to seconds.Source§fn time_elapsed_millis(elapsed: P::Elapsed) -> u64
fn time_elapsed_millis(elapsed: P::Elapsed) -> u64
elapsed to milliseconds.Source§fn time_elapsed_micros(elapsed: P::Elapsed) -> u64
fn time_elapsed_micros(elapsed: P::Elapsed) -> u64
elapsed to microseconds.Source§fn time_elapsed_nanos(elapsed: P::Elapsed) -> u64
fn time_elapsed_nanos(elapsed: P::Elapsed) -> u64
elapsed to nanoseconds.Source§fn time_now_seconds() -> u64
fn time_now_seconds() -> u64
Source§fn time_now_millis() -> u64
fn time_now_millis() -> u64
Source§fn time_now_micros() -> u64
fn time_now_micros() -> u64
Source§fn time_now_nanos() -> u64
fn time_now_nanos() -> u64
Auto Trait Implementations§
impl Freeze for JsInstant
impl RefUnwindSafe for JsInstant
impl Send for JsInstant
impl Sync for JsInstant
impl Unpin for JsInstant
impl UnsafeUnpin for JsInstant
impl UnwindSafe for JsInstant
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice only.Source§impl<T, R> Morph<R> for Twhere
T: ?Sized,
impl<T, R> Morph<R> for Twhere
T: ?Sized,
Source§impl<T, P> TimeSourceCfg<P> for Twhere
T: TimeSource<P>,
P: TimePoint,
impl<T, P> TimeSourceCfg<P> for Twhere
T: TimeSource<P>,
P: TimePoint,
Source§fn time_is_monotonic(_: ()) -> bool
fn time_is_monotonic(_: ()) -> bool
Source§fn time_is_absolute(_: ()) -> bool
fn time_is_absolute(_: ()) -> bool
Source§fn time_scale(_: ()) -> TimeScale
fn time_scale(_: ()) -> TimeScale
time_point_value and time_elapsed_value.Source§fn time_point_value(_: (), point: P) -> u64
fn time_point_value(_: (), point: P) -> u64
u64 value in time_scale(cfg) units.Source§fn time_elapsed_value(_: (), elapsed: <P as TimePoint>::Elapsed) -> u64
fn time_elapsed_value(_: (), elapsed: <P as TimePoint>::Elapsed) -> u64
u64 value in time_scale(cfg) units.Source§fn time_now_millis(_: ()) -> u64
fn time_now_millis(_: ()) -> u64
Source§fn time_now_micros(_: ()) -> u64
fn time_now_micros(_: ()) -> u64
Source§fn time_now_nanos(_: ()) -> u64
fn time_now_nanos(_: ()) -> u64
Source§fn time_now_millis_f64(_: ()) -> f64
fn time_now_millis_f64(_: ()) -> f64
f64.Source§fn time_now_value(cfg: Self::Config) -> u64
fn time_now_value(cfg: Self::Config) -> u64
u64 value in time_scale units.Source§fn time_elapsed_since(cfg: Self::Config, point: P) -> P::Elapsed
fn time_elapsed_since(cfg: Self::Config, point: P) -> P::Elapsed
point to now.Source§fn time_elapsed_since_checked(cfg: Self::Config, point: P) -> Option<P::Elapsed> ⓘ
fn time_elapsed_since_checked(cfg: Self::Config, point: P) -> Option<P::Elapsed> ⓘ
point to now,
or None if it is not valid or not representable.Source§fn time_elapsed_since_value(cfg: Self::Config, point: P) -> u64
fn time_elapsed_since_value(cfg: Self::Config, point: P) -> u64
Source§fn time_point_seconds(cfg: Self::Config, point: P) -> u64
fn time_point_seconds(cfg: Self::Config, point: P) -> u64
point to seconds.Source§fn time_point_millis(cfg: Self::Config, point: P) -> u64
fn time_point_millis(cfg: Self::Config, point: P) -> u64
point to milliseconds.Source§fn time_point_micros(cfg: Self::Config, point: P) -> u64
fn time_point_micros(cfg: Self::Config, point: P) -> u64
point to microseconds.Source§fn time_point_nanos(cfg: Self::Config, point: P) -> u64
fn time_point_nanos(cfg: Self::Config, point: P) -> u64
point to nanoseconds.Source§fn time_elapsed_seconds(cfg: Self::Config, elapsed: P::Elapsed) -> u64
fn time_elapsed_seconds(cfg: Self::Config, elapsed: P::Elapsed) -> u64
elapsed to seconds.Source§fn time_elapsed_millis(cfg: Self::Config, elapsed: P::Elapsed) -> u64
fn time_elapsed_millis(cfg: Self::Config, elapsed: P::Elapsed) -> u64
elapsed to milliseconds.Source§fn time_elapsed_micros(cfg: Self::Config, elapsed: P::Elapsed) -> u64
fn time_elapsed_micros(cfg: Self::Config, elapsed: P::Elapsed) -> u64
elapsed to microseconds.Source§fn time_elapsed_nanos(cfg: Self::Config, elapsed: P::Elapsed) -> u64
fn time_elapsed_nanos(cfg: Self::Config, elapsed: P::Elapsed) -> u64
elapsed to nanoseconds.