pub struct Duration {
value: i64,
unit: TimeUnit,
}
Expand description
Duration represents the elapsed time in either seconds, milliseconds, microseconds or nanoseconds.
Fields§
§value: i64
§unit: TimeUnit
Implementations§
source§impl Duration
impl Duration
sourcepub fn new_second(value: i64) -> Self
pub fn new_second(value: i64) -> Self
Create a new Duration in second.
sourcepub fn new_millisecond(value: i64) -> Self
pub fn new_millisecond(value: i64) -> Self
Create a new Duration in millisecond.
sourcepub fn new_microsecond(value: i64) -> Self
pub fn new_microsecond(value: i64) -> Self
Create a new Duration in microsecond.
sourcepub fn new_nanosecond(value: i64) -> Self
pub fn new_nanosecond(value: i64) -> Self
Create a new Duration in nanosecond.
sourcefn split(&self) -> (i64, u32)
fn split(&self) -> (i64, u32)
Split a Duration into seconds part and nanoseconds part. Notice the seconds part of split result is always rounded down to floor.
sourcepub fn to_std_duration(self) -> Duration
pub fn to_std_duration(self) -> Duration
Convert to std::time::Duration.
pub fn negative(self) -> Self
Trait Implementations§
source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<Duration> for Duration
impl From<Duration> for Duration
Convert from std::time::Duration to common_time::Duration Type. The range of std::time::Duration is [0, u64::MAX seconds + 999_999_999 nanoseconds] The range of common_time::Duration is [i64::MIN, i64::MAX] with TimeUnit. If the value of std::time::Duration is out of range of common_time::Duration, it will be rounded to the nearest value.
source§impl Ord for Duration
impl Ord for Duration
Duration is ordable.
source§impl PartialOrd for Duration
impl PartialOrd for Duration
impl Copy for Duration
impl Eq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request