pub struct LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,{ /* private fields */ }
Expand description
A Duration
of time stored with a limited Resolution
. This type may be
preferred to std::time::Duration
because Duration
takes a full 12
bytes to achieve its nanosecond resolution.
Converting from Duration
truncates the duration and performs no rounding.
The Resolution
type controls the storage size. The resolutions
provided by BonsaiDb:
Other resolutions can be used by implementing TimeResolution
.
Implementations§
source§impl<Resolution> LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
sourcepub const fn new(
representation: <Resolution as TimeResolution>::Representation
) -> LimitedResolutionDuration<Resolution>
pub const fn new( representation: <Resolution as TimeResolution>::Representation ) -> LimitedResolutionDuration<Resolution>
Returns a new instance with the representation
provided, which
conceptually is a unit of Resolution
.
sourcepub const fn representation(
&self
) -> <Resolution as TimeResolution>::Representation
pub const fn representation( &self ) -> <Resolution as TimeResolution>::Representation
Returns the internal representation of this duration.
Trait Implementations§
source§impl<Resolution> Clone for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Clone for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn clone(&self) -> LimitedResolutionDuration<Resolution>
fn clone(&self) -> LimitedResolutionDuration<Resolution>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<Resolution> Debug for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Debug for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§impl<Resolution> Default for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Default for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn default() -> LimitedResolutionDuration<Resolution>
fn default() -> LimitedResolutionDuration<Resolution>
Returns the “default value” for a type. Read more
source§impl<'de, Resolution> Deserialize<'de> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<'de, Resolution> Deserialize<'de> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn deserialize<D>(
deserializer: D
) -> Result<LimitedResolutionDuration<Resolution>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<LimitedResolutionDuration<Resolution>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<Resolution> Display for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Display for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§impl<Resolution, Epoch> From<LimitedResolutionDuration<Resolution>> for LimitedResolutionTimestamp<Resolution, Epoch>where
Resolution: TimeResolution,
Epoch: TimeEpoch,
impl<Resolution, Epoch> From<LimitedResolutionDuration<Resolution>> for LimitedResolutionTimestamp<Resolution, Epoch>where
Resolution: TimeResolution,
Epoch: TimeEpoch,
source§fn from(
duration: LimitedResolutionDuration<Resolution>
) -> LimitedResolutionTimestamp<Resolution, Epoch>
fn from( duration: LimitedResolutionDuration<Resolution> ) -> LimitedResolutionTimestamp<Resolution, Epoch>
Converts to this type from the input type.
source§impl<Resolution, Epoch> From<LimitedResolutionTimestamp<Resolution, Epoch>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
Epoch: TimeEpoch,
impl<Resolution, Epoch> From<LimitedResolutionTimestamp<Resolution, Epoch>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
Epoch: TimeEpoch,
source§fn from(
time: LimitedResolutionTimestamp<Resolution, Epoch>
) -> LimitedResolutionDuration<Resolution>
fn from( time: LimitedResolutionTimestamp<Resolution, Epoch> ) -> LimitedResolutionDuration<Resolution>
Converts to this type from the input type.
source§impl<Resolution> Hash for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Hash for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§impl<'k, Resolution> Key<'k> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<'k, Resolution> Key<'k> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§const CAN_OWN_BYTES: bool = false
const CAN_OWN_BYTES: bool = false
If true, this type can benefit from an owned
Vec<u8>
. This flag is
used as a hint of whether to attempt to do memcpy operations in some
decoding operations to avoid extra allocations.source§fn from_ord_bytes<'e>(
bytes: ByteSource<'k, 'e>
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding>::Error>
fn from_ord_bytes<'e>( bytes: ByteSource<'k, 'e> ) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding>::Error>
Deserialize a sequence of bytes previously encoded with
KeyEncoding::as_ord_bytes
.source§fn first_value() -> Result<Self, NextValueError>
fn first_value() -> Result<Self, NextValueError>
Return the first value in sequence for this type. Not all types
implement this.
source§fn next_value(&self) -> Result<Self, NextValueError>
fn next_value(&self) -> Result<Self, NextValueError>
Return the next value in sequence for this type. Not all types implement
this. Instead of wrapping/overflowing, None should be returned.
source§impl<Resolution> KeyEncoding for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> KeyEncoding for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§type Error = TimeError
type Error = TimeError
The error type that can be produced by either serialization or
deserialization.
source§const LENGTH: Option<usize> = None
const LENGTH: Option<usize> = None
The size of the key, if constant. If this type doesn’t produce the same
number of bytes for each value, this should be
None
.source§fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
Describes this type by invoking functions on
visitor
describing the
key being encoded. Read moresource§fn as_ord_bytes(
&self
) -> Result<Cow<'_, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding>::Error>
fn as_ord_bytes( &self ) -> Result<Cow<'_, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding>::Error>
Convert
self
into a Cow<'_, [u8]>
containing bytes that are able to be
compared via memcmp
in a way that is comptaible with its own Ord
implementation.source§impl<Resolution> Ord for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Ord for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn cmp(&self, __other: &LimitedResolutionDuration<Resolution>) -> Ordering
fn cmp(&self, __other: &LimitedResolutionDuration<Resolution>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<Resolution> PartialEq for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> PartialEq for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn eq(&self, __other: &LimitedResolutionDuration<Resolution>) -> bool
fn eq(&self, __other: &LimitedResolutionDuration<Resolution>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<Resolution> PartialOrd for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> PartialOrd for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn partial_cmp(
&self,
__other: &LimitedResolutionDuration<Resolution>
) -> Option<Ordering>
fn partial_cmp( &self, __other: &LimitedResolutionDuration<Resolution> ) -> Option<Ordering>
1.0.0 · source§fn 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 moresource§impl<Resolution> Serialize for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Serialize for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn 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
source§impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for Option<LimitedResolutionDuration<Resolution>>where
Resolution: TimeResolution,
impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for Option<LimitedResolutionDuration<Resolution>>where
Resolution: TimeResolution,
source§fn sum<I>(iter: I) -> Option<LimitedResolutionDuration<Resolution>>where
I: Iterator<Item = LimitedResolutionDuration<Resolution>>,
fn sum<I>(iter: I) -> Option<LimitedResolutionDuration<Resolution>>where
I: Iterator<Item = LimitedResolutionDuration<Resolution>>,
Method which takes an iterator and generates
Self
from the elements by
“summing up” the items.source§impl<Resolution> Sum for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Sum for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn sum<I>(iter: I) -> LimitedResolutionDuration<Resolution>where
I: Iterator<Item = LimitedResolutionDuration<Resolution>>,
fn sum<I>(iter: I) -> LimitedResolutionDuration<Resolution>where
I: Iterator<Item = LimitedResolutionDuration<Resolution>>,
Method which takes an iterator and generates
Self
from the elements by
“summing up” the items.source§impl<Resolution> TryFrom<Duration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> TryFrom<Duration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for Durationwhere
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for Durationwhere
Resolution: TimeResolution,
source§impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for SignedDurationwhere
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for SignedDurationwhere
Resolution: TimeResolution,
source§fn try_from(
value: LimitedResolutionDuration<Resolution>
) -> Result<SignedDuration, <SignedDuration as TryFrom<LimitedResolutionDuration<Resolution>>>::Error>
fn try_from( value: LimitedResolutionDuration<Resolution> ) -> Result<SignedDuration, <SignedDuration as TryFrom<LimitedResolutionDuration<Resolution>>>::Error>
Performs the conversion.
source§impl<Resolution> TryFrom<SignedDuration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> TryFrom<SignedDuration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
source§fn try_from(
duration: SignedDuration
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as TryFrom<SignedDuration>>::Error>
fn try_from( duration: SignedDuration ) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as TryFrom<SignedDuration>>::Error>
Performs the conversion.
impl<Resolution> Copy for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Eq for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
Auto Trait Implementations§
impl<Resolution> RefUnwindSafe for LimitedResolutionDuration<Resolution>
impl<Resolution> Send for LimitedResolutionDuration<Resolution>
impl<Resolution> Sync for LimitedResolutionDuration<Resolution>
impl<Resolution> Unpin for LimitedResolutionDuration<Resolution>
impl<Resolution> UnwindSafe for LimitedResolutionDuration<Resolution>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
§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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key
and return true
if they are equal.