Struct holochain::prelude::dependencies::kitsune_p2p_types::dht::spacetime::TelescopingTimes
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
impl TelescopingTimes
impl TelescopingTimes
pub fn empty() -> TelescopingTimes
pub fn empty() -> TelescopingTimes
An empty set of times
pub fn new(time: TimeQuantum) -> TelescopingTimes
pub fn new(time: TimeQuantum) -> TelescopingTimes
Constructor,
pub fn historical(topo: &Topology) -> TelescopingTimes
pub fn historical(topo: &Topology) -> TelescopingTimes
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.)
pub fn segments(&self) -> Vec<Segment<TimeOffset>, Global> ⓘ
pub fn segments(&self) -> Vec<Segment<TimeOffset>, Global> ⓘ
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.
pub fn limit(&self, limit: u32) -> TelescopingTimes
pub fn limit(&self, limit: u32) -> TelescopingTimes
Set a limit
pub fn rectify<T>(
a: (&TelescopingTimes, &mut Vec<T, Global>),
b: (&TelescopingTimes, &mut Vec<T, Global>)
)where
T: AddAssign<T>,
pub fn rectify<T>(
a: (&TelescopingTimes, &mut Vec<T, Global>),
b: (&TelescopingTimes, &mut Vec<T, Global>)
)where
T: AddAssign<T>,
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
impl Clone for TelescopingTimes
impl Clone for TelescopingTimes
fn clone(&self) -> TelescopingTimes
fn clone(&self) -> TelescopingTimes
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreimpl Debug for TelescopingTimes
impl Debug for TelescopingTimes
impl<'de> Deserialize<'de> for TelescopingTimes
impl<'de> Deserialize<'de> for TelescopingTimes
fn deserialize<__D>(
__deserializer: __D
) -> Result<TelescopingTimes, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<TelescopingTimes, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Ord for TelescopingTimes
impl Ord for TelescopingTimes
fn cmp(&self, other: &TelescopingTimes) -> Ordering
fn cmp(&self, other: &TelescopingTimes) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
impl PartialEq<TelescopingTimes> for TelescopingTimes
impl PartialEq<TelescopingTimes> for TelescopingTimes
fn eq(&self, other: &TelescopingTimes) -> bool
fn eq(&self, other: &TelescopingTimes) -> bool
impl PartialOrd<TelescopingTimes> for TelescopingTimes
impl PartialOrd<TelescopingTimes> for TelescopingTimes
fn partial_cmp(&self, other: &TelescopingTimes) -> Option<Ordering>
fn partial_cmp(&self, other: &TelescopingTimes) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Serialize for TelescopingTimes
impl Serialize for TelescopingTimes
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,
impl Copy for TelescopingTimes
impl Eq for TelescopingTimes
impl StructuralEq for TelescopingTimes
impl StructuralPartialEq for TelescopingTimes
Auto Trait Implementations
impl RefUnwindSafe for TelescopingTimes
impl Send for TelescopingTimes
impl Sync for TelescopingTimes
impl Unpin for TelescopingTimes
impl UnwindSafe for TelescopingTimes
Blanket Implementations
impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
sourceimpl<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,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.impl<T> FutureExt for T
impl<T> FutureExt for T
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
sourcefn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
sourcefn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.