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 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
.
pub 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§
§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<Resolution> Hash for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Hash for LimitedResolutionDuration<Resolution>where Resolution: TimeResolution,
§impl<'k, Resolution> Key<'k> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<'k, Resolution> Key<'k> for LimitedResolutionDuration<Resolution>where Resolution: TimeResolution,
§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.§fn from_ord_bytes<'e>(
bytes: ByteSource<'k, 'e>
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding<LimitedResolutionDuration<Resolution>>>::Error>
fn from_ord_bytes<'e>( bytes: ByteSource<'k, 'e> ) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding<LimitedResolutionDuration<Resolution>>>::Error>
Deserialize a sequence of bytes previously encoded with
KeyEncoding::as_ord_bytes
.§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.
§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.
§impl<Resolution> KeyEncoding<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> KeyEncoding<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.
§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
.§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 more§fn as_ord_bytes(
&self
) -> Result<Cow<'_, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding<LimitedResolutionDuration<Resolution>>>::Error>
fn as_ord_bytes( &self ) -> Result<Cow<'_, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding<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.§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
This method tests for
self
and other
values to be equal, and is used
by ==
.§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> Sum<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where Resolution: TimeResolution,
§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.§impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for Option<LimitedResolutionDuration<Resolution>>where
Resolution: TimeResolution,
impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for Option<LimitedResolutionDuration<Resolution>>where Resolution: TimeResolution,
§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.§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§
§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
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.§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,
§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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.