Struct kitsune_p2p_dht::spacetime::Topology

source ·
pub struct Topology {
    pub space: SpaceDimension,
    pub time: TimeDimension,
    pub time_origin: Timestamp,
    pub time_cutoff: Duration,
}
Expand description

Topology defines the structure of spacetime, in particular how space and time are quantized.

Any calculation which requires converting from absolute coordinates to quantized coordinates must refer to the topology. Therefore, this type is ubiquitous! More functions than not take it as a parameter. This may seem cumbersome, but there are a few reasons why this is helpful:

  • We currently use a “standard” quantization for all networks, but we may find it beneficial in the future to let each network specify its own quantization levels, based on its own traffic and longevity needs.
  • It is confusing to be working with three different coordinate systems in this codebase, and the presence of a &topo param in a function is a helpful reminder to be extra mindful about the unit conversions that are happening

Fields§

§space: SpaceDimension

The quantization of space

§time: TimeDimension

The quantization of time

§time_origin: Timestamp

The origin of time, meaning the 0th quantum contains this Timestamp.

§time_cutoff: Duration

Ignore any data which lies after Timestamp::now() - time_cutoff. This is so that historical quantized gossip does not overlap with recent gossip.

Implementations§

source§

impl Topology

source

pub fn standard(time_origin: Timestamp, time_cutoff: Duration) -> Self

Standard dimensions with the given time origin

source

pub fn standard_epoch(time_cutoff: Duration) -> Self

Standard dimensions with the HOLOCHAIN_EPOCH as the time origin

source

pub fn standard_epoch_full() -> Self

Standard dimensions with the HOLOCHAIN_EPOCH as the time origin

source

pub fn space_quantum(&self, x: Loc) -> SpaceQuantum

Returns the space quantum which contains this location

source

pub fn time_quantum(&self, t: Timestamp) -> TimeQuantum

Returns the time quantum which contains this timestamp

source

pub fn time_quantum_duration(&self, d: Duration) -> TimeQuantum

Returns the time quantum which contains this timestamp

source

pub fn min_space_power(&self) -> u8

The minimum power to use in “exponentional coordinates”.

source

pub fn max_space_power(&self, strat: &ArqStrat) -> u8

The maximum power to use in “exponentional coordinates”. This is 17 for standard space topology. (32 - 12 - 3)

Trait Implementations§

source§

impl AsRef<SpaceDimension> for Topology

source§

fn as_ref(&self) -> &SpaceDimension

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<TimeDimension> for Topology

source§

fn as_ref(&self) -> &TimeDimension

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Topology

source§

fn clone(&self) -> Topology

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Topology

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Topology> for SpaceDimension

source§

fn from(topo: &'a Topology) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Topology> for TimeDimension

source§

fn from(topo: &'a Topology) -> Self

Converts to this type from the input type.
source§

impl From<Topology> for SpaceDimension

source§

fn from(topo: Topology) -> Self

Converts to this type from the input type.
source§

impl From<Topology> for TimeDimension

source§

fn from(topo: Topology) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Topology

source§

fn eq(&self, other: &Topology) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Topology

source§

impl StructuralPartialEq for Topology

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,