Struct bonsaidb::core::key::time::limited::LimitedResolutionDuration [−][src]
pub struct LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution, { /* fields omitted */ }
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
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,
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,
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,
pub fn deserialize<D>(
deserializer: D
) -> Result<LimitedResolutionDuration<Resolution>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub 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,
pub fn from(
duration: LimitedResolutionDuration<Resolution>
) -> LimitedResolutionTimestamp<Resolution, Epoch>
pub fn from(
duration: LimitedResolutionDuration<Resolution>
) -> LimitedResolutionTimestamp<Resolution, Epoch>
Performs the conversion.
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,
pub fn from(
time: LimitedResolutionTimestamp<Resolution, Epoch>
) -> LimitedResolutionDuration<Resolution>
pub fn from(
time: LimitedResolutionTimestamp<Resolution, Epoch>
) -> LimitedResolutionDuration<Resolution>
Performs the conversion.
impl<'a, Resolution> Key<'a> for LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution,
impl<'a, Resolution> Key<'a> for LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution,
pub fn from_ord_bytes(
bytes: &'a [u8]
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as KeyEncoding<'a, LimitedResolutionDuration<Resolution>>>::Error>
pub 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
Return the first value in sequence for this type. Not all types implement this. Read more
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,
The error type that can be produced by either serialization or deserialization. Read more
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
pub fn as_ord_bytes(
&'a self
) -> Result<Cow<'a, [u8]>, <LimitedResolutionDuration<Resolution> as KeyEncoding<'a, LimitedResolutionDuration<Resolution>>>::Error>
pub 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,
impl<Resolution> PartialEq<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution,
impl<Resolution> PartialEq<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution,
impl<Resolution> PartialOrd<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution,
impl<Resolution> PartialOrd<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution> where
Resolution: TimeResolution,
pub fn partial_cmp(
&self,
__other: &LimitedResolutionDuration<Resolution>
) -> Option<Ordering>
pub fn partial_cmp(
&self,
__other: &LimitedResolutionDuration<Resolution>
) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (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,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub 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 Duration where
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for Duration where
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for SignedDuration where
Resolution: TimeResolution,
impl<Resolution> TryFrom<LimitedResolutionDuration<Resolution>> for SignedDuration where
Resolution: TimeResolution,
pub fn try_from(
value: LimitedResolutionDuration<Resolution>
) -> Result<SignedDuration, <SignedDuration as TryFrom<LimitedResolutionDuration<Resolution>>>::Error>
pub 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,
pub fn try_from(
duration: SignedDuration
) -> Result<LimitedResolutionDuration<Resolution>, <LimitedResolutionDuration<Resolution> as TryFrom<SignedDuration>>::Error>
pub 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
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more