Struct bonsaidb_core::key::time::limited::LimitedResolutionDuration
source · pub struct LimitedResolutionDuration<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::Representation) -> Self
pub const fn new(representation: Resolution::Representation) -> Self
Returns a new instance with the representation
provided, which
conceptually is a unit of Resolution
.
sourcepub const fn representation(&self) -> Resolution::Representation
pub const fn representation(&self) -> Resolution::Representation
Returns the internal representation of this duration.
Trait Implementations§
source§impl<Resolution: TimeResolution> Clone for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> Clone for LimitedResolutionDuration<Resolution>
source§impl<Resolution: TimeResolution> Debug for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> Debug for LimitedResolutionDuration<Resolution>
source§impl<Resolution> Default for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Default for LimitedResolutionDuration<Resolution>where Resolution: TimeResolution,
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<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<Resolution: TimeResolution> Display for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> Display for LimitedResolutionDuration<Resolution>
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>) -> Self
fn from(duration: LimitedResolutionDuration<Resolution>) -> Self
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>) -> Self
fn from(time: LimitedResolutionTimestamp<Resolution, Epoch>) -> Self
Converts to this type from the input type.
source§impl<Resolution: TimeResolution> Hash for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> Hash for LimitedResolutionDuration<Resolution>
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<Self, Self::Error>
fn from_ord_bytes<'e>(bytes: ByteSource<'k, 'e>) -> Result<Self, Self::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<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.
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§impl<Resolution: TimeResolution> Ord for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> Ord for LimitedResolutionDuration<Resolution>
source§impl<Resolution: TimeResolution> PartialEq<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> PartialEq<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>
source§impl<Resolution: TimeResolution> PartialOrd<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> PartialOrd<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>
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§impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> Sum<LimitedResolutionDuration<Resolution>> for LimitedResolutionDuration<Resolution>where Resolution: TimeResolution,
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: Iterator<Item = LimitedResolutionDuration<Resolution>>>(
iter: I
) -> Self
fn sum<I: Iterator<Item = LimitedResolutionDuration<Resolution>>>( iter: I ) -> Self
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§impl<Resolution> TryFrom<SignedDuration> for LimitedResolutionDuration<Resolution>where
Resolution: TimeResolution,
impl<Resolution> TryFrom<SignedDuration> for LimitedResolutionDuration<Resolution>where Resolution: TimeResolution,
impl<Resolution: TimeResolution> Copy for LimitedResolutionDuration<Resolution>
impl<Resolution: TimeResolution> Eq for LimitedResolutionDuration<Resolution>
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<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