pub struct TelescopingTimes { /* private fields */ }
Expand description

A type which generates a sequence of exponentially expanding TimeSegments, with the smallest possible segment covering the most recent time, and larger segments as we go further back in time.

The segments completely cover the set of time quanta from 0 to the specified time parameter. The segments never overlap.

The set of segments grows logarithmically with the number of time quanta to be covered.

Implementations

An empty set of times

Constructor,

Get TelescopingTimes from the origin time up until times less than recent_threshold ago, to be handled by historical gossip. (Recent gossip will handle everything after the threshold.)

Calculate the exponentially expanding time segments using the binary representation of the current timestamp.

The intuition for this algorithm is that the position of the most significant 1 represents the power of the largest, leftmost time segment, and subsequent bits represent the powers of 2 below that one. After the MSB, a 0 represents a single value of the power represented by that bit, and a 1 represents two values of the power at that bit.

See the test below which has the first 16 time segments, each alongside the binary representation of the timestamp (+1) which generated it. Seeing the pattern in that test is the best way to understand this.

Set a limit

Modify the region data associated with two different TelescopingTimes of different lengths, so that both data vectors are referring to the same regions.

In general, when one TelescopingTimes sequence is longer than another, the longer sequence will have larger TimeSegments than the shorter one. To rectify them, the shorter sequence needs to merge some of its earlier data until it has a segment large enough to match the larger segment of the other sequence. This continues until all segments of the smaller sequence are exhausted. Then, the longer sequence is truncated to match the shorter one.

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
Deserialize this value from the given Serde deserializer. 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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745 Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
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
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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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
The type for metadata in pointers and references to Self.
Should always be Self
Performance hack: Clone doesn’t get inlined for Copy types in debug mode, so make it inline anyway.
Tests if Self the same as the type T Read more
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. 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.
upcast ref
upcast mut ref
upcast boxed dyn
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
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