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§
§impl<Resolution> LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
pub fn new(
step: <Resolution as TimeResolution>::Representation
) -> LimitedResolutionDuration<Resolution>
pub fn new(
step: <Resolution as TimeResolution>::Representation
) -> LimitedResolutionDuration<Resolution>
Returns a new instance with the step
provided, which conceptually
is a unit of Resolution
.
Trait Implementations§
§impl<Resolution> Clone for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Clone for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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 more§impl<Resolution> Debug for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Debug for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§impl<Resolution> Default for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Default for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§fn default() -> LimitedResolutionDuration<Resolution>
fn default() -> LimitedResolutionDuration<Resolution>
Returns the “default value” for a type. Read more
§impl<'de, Resolution> Deserialize<'de> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<'de, Resolution> Deserialize<'de> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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
§impl<Resolution> Display for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Display for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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,
§fn from(
duration: LimitedResolutionDuration<Resolution>
) -> LimitedResolutionTimestamp<Resolution, Epoch>
fn from(
duration: LimitedResolutionDuration<Resolution>
) -> LimitedResolutionTimestamp<Resolution, Epoch>
Converts to this type from the input type.
§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,
§fn from(
time: LimitedResolutionTimestamp<Resolution, Epoch>
) -> LimitedResolutionDuration<Resolution>
fn from(
time: LimitedResolutionTimestamp<Resolution, Epoch>
) -> LimitedResolutionDuration<Resolution>
Converts to this type from the input type.
§impl<'a, Resolution> Key<'a> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<'a, Resolution> Key<'a> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§fn from_ord_bytes(
bytes: &'a [u8]
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding<'a, LimitedResolutionDuration<Resolution>>>::Error>
fn from_ord_bytes(
bytes: &'a [u8]
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding<'a, LimitedResolutionDuration<Resolution>>>::Error>
Deserialize a sequence of bytes previously encoded with
KeyEncoding::as_ord_bytes
. Read more§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. Read more
§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. Read more
§impl<'a, Resolution> KeyEncoding<'a, LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<'a, Resolution> KeyEncoding<'a, LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§type Error = TimeError
type Error = TimeError
The error type that can be produced by either serialization or
deserialization. Read more
§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
. Read more§fn as_ord_bytes(
&'a self
) -> Result<Cow<'a, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding<'a, LimitedResolutionDuration<Resolution>>>::Error>
fn as_ord_bytes(
&'a self
) -> Result<Cow<'a, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding<'a, LimitedResolutionDuration<Resolution>>>::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. Read more§impl<Resolution> Ord for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Ord for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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
§impl<Resolution> PartialEq<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> PartialEq<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§fn eq(&self, __other: &LimitedResolutionDuration<Resolution>) -> bool
fn eq(&self, __other: &LimitedResolutionDuration<Resolution>) -> bool
§impl<Resolution> PartialOrd<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> PartialOrd<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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 more§impl<Resolution> Serialize for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Serialize for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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
§impl<Resolution> TryFrom<Duration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> TryFrom<Duration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for Durationwhere
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for Durationwhere
Resolution: TimeResolution,
§impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for SignedDurationwhere
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for SignedDurationwhere
Resolution: TimeResolution,
§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.
§impl<Resolution> TryFrom<SignedDuration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> TryFrom<SignedDuration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
§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>where
Resolution: RefUnwindSafe,
<Resolution as TimeResolution>::Representation: RefUnwindSafe,
impl<Resolution> Send for LimitedResolutionDuration<Resolution>
impl<Resolution> Sync for LimitedResolutionDuration<Resolution>
impl<Resolution> Unpin for LimitedResolutionDuration<Resolution>where
Resolution: Unpin,
<Resolution as TimeResolution>::Representation: Unpin,
impl<Resolution> UnwindSafe for LimitedResolutionDuration<Resolution>where
Resolution: UnwindSafe,
<Resolution as TimeResolution>::Representation: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.