Struct alloc_data::prelude::time::SinceStart
source · [−]pub struct SinceStart { /* private fields */ }
Expand description
Wrapper around a duration.
This type represents a point in time relative to the start time of the run of the program
being profiled, which is a Date
(an absolute point in time).
Implementations
sourceimpl SinceStart
impl SinceStart
sourcepub fn zero() -> SinceStart
pub fn zero() -> SinceStart
A duration of 0 nanoseconds.
sourcepub fn one_sec() -> SinceStart
pub fn one_sec() -> SinceStart
A duration of 1 second.
sourcepub fn from_secs(secs: u64) -> SinceStart
pub fn from_secs(secs: u64) -> SinceStart
Constructor from an amount of seconds.
sourcepub fn from_nano_timestamp(secs: u64, nanos: u32) -> SinceStart
pub fn from_nano_timestamp(secs: u64, nanos: u32) -> SinceStart
Constructor from a timestamp in nanos seconds.
sourcepub fn to_lifetime(self) -> Lifetime
pub fn to_lifetime(self) -> Lifetime
Turns itself in a lifetime.
Methods from Deref<Target = Duration>
pub const SECOND: Duration = Duration::from_secs(1)
pub const MILLISECOND: Duration = Duration::from_millis(1)
pub const MICROSECOND: Duration = Duration::from_micros(1)
pub const NANOSECOND: Duration = Duration::from_nanos(1)
pub const ZERO: Duration = Duration::from_nanos(0)
pub const MAX: Duration = Duration::new(u64::MAX, NANOS_PER_SEC - 1)
1.53.0 · sourcepub fn is_zero(&self) -> bool
pub fn is_zero(&self) -> bool
Returns true if this Duration
spans no time.
Examples
use std::time::Duration;
assert!(Duration::ZERO.is_zero());
assert!(Duration::new(0, 0).is_zero());
assert!(Duration::from_nanos(0).is_zero());
assert!(Duration::from_secs(0).is_zero());
assert!(!Duration::new(1, 1).is_zero());
assert!(!Duration::from_nanos(1).is_zero());
assert!(!Duration::from_secs(1).is_zero());
1.3.0 · sourcepub fn as_secs(&self) -> u64
pub fn as_secs(&self) -> u64
Returns the number of whole seconds contained by this Duration
.
The returned value does not include the fractional (nanosecond) part of the
duration, which can be obtained using subsec_nanos
.
Examples
use std::time::Duration;
let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_secs(), 5);
To determine the total number of seconds represented by the Duration
,
use as_secs
in combination with subsec_nanos
:
use std::time::Duration;
let duration = Duration::new(5, 730023852);
assert_eq!(5.730023852,
duration.as_secs() as f64
+ duration.subsec_nanos() as f64 * 1e-9);
1.27.0 · sourcepub fn subsec_millis(&self) -> u32
pub fn subsec_millis(&self) -> u32
Returns the fractional part of this Duration
, in whole milliseconds.
This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).
Examples
use std::time::Duration;
let duration = Duration::from_millis(5432);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_millis(), 432);
1.27.0 · sourcepub fn subsec_micros(&self) -> u32
pub fn subsec_micros(&self) -> u32
Returns the fractional part of this Duration
, in whole microseconds.
This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).
Examples
use std::time::Duration;
let duration = Duration::from_micros(1_234_567);
assert_eq!(duration.as_secs(), 1);
assert_eq!(duration.subsec_micros(), 234_567);
1.3.0 · sourcepub fn subsec_nanos(&self) -> u32
pub fn subsec_nanos(&self) -> u32
Returns the fractional part of this Duration
, in nanoseconds.
This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one billion).
Examples
use std::time::Duration;
let duration = Duration::from_millis(5010);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_nanos(), 10_000_000);
1.33.0 · sourcepub fn as_millis(&self) -> u128
pub fn as_millis(&self) -> u128
Returns the total number of whole milliseconds contained by this Duration
.
Examples
use std::time::Duration;
let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_millis(), 5730);
1.33.0 · sourcepub fn as_micros(&self) -> u128
pub fn as_micros(&self) -> u128
Returns the total number of whole microseconds contained by this Duration
.
Examples
use std::time::Duration;
let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_micros(), 5730023);
1.33.0 · sourcepub fn as_nanos(&self) -> u128
pub fn as_nanos(&self) -> u128
Returns the total number of nanoseconds contained by this Duration
.
Examples
use std::time::Duration;
let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_nanos(), 5730023852);
1.38.0 · sourcepub fn as_secs_f64(&self) -> f64
pub fn as_secs_f64(&self) -> f64
Returns the number of seconds contained by this Duration
as f64
.
The returned value does include the fractional (nanosecond) part of the duration.
Examples
use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f64(), 2.7);
1.38.0 · sourcepub fn as_secs_f32(&self) -> f32
pub fn as_secs_f32(&self) -> f32
Returns the number of seconds contained by this Duration
as f32
.
The returned value does include the fractional (nanosecond) part of the duration.
Examples
use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f32(), 2.7);
Trait Implementations
sourceimpl<'a, 'b> Add<&'a SinceStart> for &'b Date
impl<'a, 'b> Add<&'a SinceStart> for &'b Date
sourcefn add(
self,
duration: &'a SinceStart
) -> <&'b Date as Add<&'a SinceStart>>::Output
fn add(
self,
duration: &'a SinceStart
) -> <&'b Date as Add<&'a SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl<'a, 'b> Add<&'a SinceStart> for &'b SinceStart
impl<'a, 'b> Add<&'a SinceStart> for &'b SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the +
operator.
sourcefn add(self, other: &'a SinceStart) -> SinceStart
fn add(self, other: &'a SinceStart) -> SinceStart
Performs the +
operation. Read more
sourceimpl<'a> Add<&'a SinceStart> for Date
impl<'a> Add<&'a SinceStart> for Date
sourcefn add(self, duration: &'a SinceStart) -> <Date as Add<&'a SinceStart>>::Output
fn add(self, duration: &'a SinceStart) -> <Date as Add<&'a SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl<'a> Add<&'a SinceStart> for SinceStart
impl<'a> Add<&'a SinceStart> for SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the +
operator.
sourcefn add(self, other: &'a SinceStart) -> SinceStart
fn add(self, other: &'a SinceStart) -> SinceStart
Performs the +
operation. Read more
sourceimpl<'a> Add<SinceStart> for &'a Date
impl<'a> Add<SinceStart> for &'a Date
sourcefn add(self, duration: SinceStart) -> <&'a Date as Add<SinceStart>>::Output
fn add(self, duration: SinceStart) -> <&'a Date as Add<SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl<'a> Add<SinceStart> for &'a SinceStart
impl<'a> Add<SinceStart> for &'a SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the +
operator.
sourcefn add(self, other: SinceStart) -> SinceStart
fn add(self, other: SinceStart) -> SinceStart
Performs the +
operation. Read more
sourceimpl Add<SinceStart> for Date
impl Add<SinceStart> for Date
Adds a duration.
Examples
use base::prelude::time::*;
let (secs, subsec_nanos) = (1_566_489_242, 7_000_572);
let mut date = Date::from_timestamp(secs, subsec_nanos);
let duration = SinceStart::parse_secs("7.003000001").unwrap();
date = date + duration;
assert_eq! { date.timestamp(), (secs + 7, subsec_nanos + 3_000_001) }
sourcefn add(self, duration: SinceStart) -> <Date as Add<SinceStart>>::Output
fn add(self, duration: SinceStart) -> <Date as Add<SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl Add<SinceStart> for SinceStart
impl Add<SinceStart> for SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the +
operator.
sourcefn add(self, other: SinceStart) -> SinceStart
fn add(self, other: SinceStart) -> SinceStart
Performs the +
operation. Read more
sourceimpl Clone for SinceStart
impl Clone for SinceStart
sourcefn clone(&self) -> SinceStart
fn clone(&self) -> SinceStart
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SinceStart
impl Debug for SinceStart
sourceimpl Deref for SinceStart
impl Deref for SinceStart
sourceimpl<'de> Deserialize<'de> for SinceStart
impl<'de> Deserialize<'de> for SinceStart
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<SinceStart, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<SinceStart, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for SinceStart
impl Display for SinceStart
sourceimpl<'a> Div<u32> for &'a SinceStart
impl<'a> Div<u32> for &'a SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the /
operator.
sourcefn div(self, ratio: u32) -> SinceStart
fn div(self, ratio: u32) -> SinceStart
Performs the /
operation. Read more
sourceimpl Div<u32> for SinceStart
impl Div<u32> for SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the /
operator.
sourcefn div(self, ratio: u32) -> SinceStart
fn div(self, ratio: u32) -> SinceStart
Performs the /
operation. Read more
sourceimpl DurationExt for SinceStart
impl DurationExt for SinceStart
sourcefn as_duration(&self) -> &Duration
fn as_duration(&self) -> &Duration
Retrieves the duration from Self
.
sourcefn to_chrono_duration(&self) -> Duration
fn to_chrono_duration(&self) -> Duration
Retrieves the chrono duration from Self
.
sourcefn from_micros(ts: u64) -> Self
fn from_micros(ts: u64) -> Self
Creates a duration from a timestamp in microseconds.
sourcefn parse_secs<Str>(ts: &Str) -> Result<Self, Error> where
Str: AsRef<str> + ?Sized,
fn parse_secs<Str>(ts: &Str) -> Result<Self, Error> where
Str: AsRef<str> + ?Sized,
Duration parser from an amount of seconds, seen as a float. Read more
sourcefn display_millis(&'me self) -> DurationDisplay<'me, Self, Millis>
fn display_millis(&'me self) -> DurationDisplay<'me, Self, Millis>
Pretty displayable version of a duration, millisecond precision.
sourcefn display_micros(&'me self) -> DurationDisplay<'me, Self, Micros>
fn display_micros(&'me self) -> DurationDisplay<'me, Self, Micros>
Pretty displayable version of a duration, microsecond precision.
sourcefn display_nanos(&'me self) -> DurationDisplay<'me, Self, Nanos>
fn display_nanos(&'me self) -> DurationDisplay<'me, Self, Nanos>
Pretty displayable version of a duration, nanosecond precision.
sourceimpl From<Duration> for SinceStart
impl From<Duration> for SinceStart
sourcefn from(duration: Duration) -> SinceStart
fn from(duration: Duration) -> SinceStart
Converts to this type from the input type.
sourceimpl Hash for SinceStart
impl Hash for SinceStart
sourceimpl Into<Duration> for SinceStart
impl Into<Duration> for SinceStart
sourceimpl Ord for SinceStart
impl Ord for SinceStart
sourcefn cmp(&self, other: &SinceStart) -> Ordering
fn cmp(&self, other: &SinceStart) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl Parseable for SinceStart
impl Parseable for SinceStart
sourceimpl PartialEq<SinceStart> for SinceStart
impl PartialEq<SinceStart> for SinceStart
sourcefn eq(&self, other: &SinceStart) -> bool
fn eq(&self, other: &SinceStart) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SinceStart) -> bool
fn ne(&self, other: &SinceStart) -> bool
This method tests for !=
.
sourceimpl PartialOrd<SinceStart> for SinceStart
impl PartialOrd<SinceStart> for SinceStart
sourcefn partial_cmp(&self, other: &SinceStart) -> Option<Ordering>
fn partial_cmp(&self, other: &SinceStart) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl Serialize for SinceStart
impl Serialize for SinceStart
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'a, 'b> Sub<&'a SinceStart> for &'b SinceStart
impl<'a, 'b> Sub<&'a SinceStart> for &'b SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the -
operator.
sourcefn sub(self, other: &'a SinceStart) -> SinceStart
fn sub(self, other: &'a SinceStart) -> SinceStart
Performs the -
operation. Read more
sourceimpl<'a> Sub<&'a SinceStart> for Date
impl<'a> Sub<&'a SinceStart> for Date
sourcefn sub(self, duration: &'a SinceStart) -> <Date as Sub<&'a SinceStart>>::Output
fn sub(self, duration: &'a SinceStart) -> <Date as Sub<&'a SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl<'a> Sub<&'a SinceStart> for SinceStart
impl<'a> Sub<&'a SinceStart> for SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the -
operator.
sourcefn sub(self, other: &'a SinceStart) -> SinceStart
fn sub(self, other: &'a SinceStart) -> SinceStart
Performs the -
operation. Read more
sourceimpl<'a, 'b> Sub<&'b SinceStart> for &'a Date
impl<'a, 'b> Sub<&'b SinceStart> for &'a Date
sourcefn sub(
self,
duration: &'b SinceStart
) -> <&'a Date as Sub<&'b SinceStart>>::Output
fn sub(
self,
duration: &'b SinceStart
) -> <&'a Date as Sub<&'b SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl<'a> Sub<SinceStart> for &'a Date
impl<'a> Sub<SinceStart> for &'a Date
sourcefn sub(self, duration: SinceStart) -> <&'a Date as Sub<SinceStart>>::Output
fn sub(self, duration: SinceStart) -> <&'a Date as Sub<SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl<'a> Sub<SinceStart> for &'a SinceStart
impl<'a> Sub<SinceStart> for &'a SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the -
operator.
sourcefn sub(self, other: SinceStart) -> SinceStart
fn sub(self, other: SinceStart) -> SinceStart
Performs the -
operation. Read more
sourceimpl Sub<SinceStart> for Date
impl Sub<SinceStart> for Date
sourcefn sub(self, duration: SinceStart) -> <Date as Sub<SinceStart>>::Output
fn sub(self, duration: SinceStart) -> <Date as Sub<SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl Sub<SinceStart> for SinceStart
impl Sub<SinceStart> for SinceStart
type Output = SinceStart
type Output = SinceStart
The resulting type after applying the -
operator.
sourcefn sub(self, other: SinceStart) -> SinceStart
fn sub(self, other: SinceStart) -> SinceStart
Performs the -
operation. Read more
impl Copy for SinceStart
impl Eq for SinceStart
impl StructuralEq for SinceStart
impl StructuralPartialEq for SinceStart
Auto Trait Implementations
impl RefUnwindSafe for SinceStart
impl Send for SinceStart
impl Sync for SinceStart
impl Unpin for SinceStart
impl UnwindSafe for SinceStart
Blanket Implementations
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
type Err = NoError
type Err = NoError
The error type produced by a failed conversion.
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ConvUtil for T
impl<T> ConvUtil for T
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Approximate the subject to a given type with the default scheme.
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
type Err = NoError
type Err = NoError
The error type produced by a failed conversion.
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
type Err = <Dst as ValueFrom<Src>>::Err
type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.