Struct bonsaidb::core::key::time::limited::LimitedResolutionTimestamp[][src]

pub struct LimitedResolutionTimestamp<Resolution, Epoch>(_, _)
where
    Resolution: TimeResolution,
    Epoch: TimeEpoch
;
Expand description

A timestamp (moment in time) stored with a limited Resolution. This type may be preferred to std::time::SystemTime because SystemTime serializes with nanosecond resolution. Often this level of precision is not needed and less storage and memory can be used.

This type stores the representation of the timestamp as a LimitedResolutionDuration relative to Epoch.

The Resolution type controls the storage size. The resolutions provided by BonsaiDb:

Other resolutions can be used by implementing TimeResolution. BonsaiDb provides two TimeEpoch implementations:

Implementations

Returns SystemTime::now() limited to Resolution. The timestamp will be truncated, not rounded.

Returns the Duration since January 1, 1970 00:00:00 UTC for this timestamp.

Converts this value to a a decimal string containing the number of seconds since the unix epoch (January 1, 1970 00:00:00 UTC).

The resulting string can be parsed as well.

use bonsaidb_core::key::time::limited::{
    BonsaiEpoch, LimitedResolutionTimestamp, Milliseconds,
};

let now = LimitedResolutionTimestamp::<Milliseconds, BonsaiEpoch>::now();
let timestamp = now.to_timestamp_string().unwrap();
let parsed = timestamp.parse().unwrap();
assert_eq!(now, parsed);

The difference between this function and to_string()] is that to_string() will revert to using the underlying LimitedResolutionDuration’s to_string() if a value is unable to be converted to a value relative to the unix epoch.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

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

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

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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