Struct kitsune_p2p_dht::spacetime::Segment
source · pub struct Segment<O: Offset> {
pub power: u8,
pub offset: O,
}
Expand description
Any interval in space or time is represented by a node in a tree, so our way of describing intervals uses tree coordinates as well: The length of an interval is 2^(power), and the position of its left edge is at (offset * length).
Fields§
§power: u8
The exponent, where length = 2^power
offset: O
The offset from the origin, measured in number of lengths
Implementations§
source§impl<O: Offset> Segment<O>
impl<O: Offset> Segment<O>
sourcepub fn num_quanta(&self) -> u64
pub fn num_quanta(&self) -> u64
How many quanta does this segment cover?
sourcepub fn absolute_length(&self, topo: &Topology) -> u64
pub fn absolute_length(&self, topo: &Topology) -> u64
The length, in absolute terms (Location or microseconds of time)
sourcepub fn quantum_bounds(&self, topo: &Topology) -> (O::Quantum, O::Quantum)
pub fn quantum_bounds(&self, topo: &Topology) -> (O::Quantum, O::Quantum)
Get the quanta which bound this segment
sourcepub fn contains_quantum(&self, topo: &Topology, coord: O::Quantum) -> bool
pub fn contains_quantum(&self, topo: &Topology, coord: O::Quantum) -> bool
The segment contains the given quantum coord
source§impl Segment<SpaceOffset>
impl Segment<SpaceOffset>
sourcepub fn loc_bounds(&self, topo: &Topology) -> (Loc, Loc)
pub fn loc_bounds(&self, topo: &Topology) -> (Loc, Loc)
Get the start and end bounds, in absolute Loc coordinates, for this segment
source§impl Segment<TimeOffset>
impl Segment<TimeOffset>
sourcepub fn timestamp_bounds(&self, topo: &Topology) -> (Timestamp, Timestamp)
pub fn timestamp_bounds(&self, topo: &Topology) -> (Timestamp, Timestamp)
Get the start and end bounds, in absolute Timestamp coordinates, for this segment
Trait Implementations§
source§impl<'de, O> Deserialize<'de> for Segment<O>where
O: Deserialize<'de> + Offset,
impl<'de, O> Deserialize<'de> for Segment<O>where
O: Deserialize<'de> + Offset,
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<O: Ord + Offset> Ord for Segment<O>
impl<O: Ord + Offset> Ord for Segment<O>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<O: PartialEq + Offset> PartialEq for Segment<O>
impl<O: PartialEq + Offset> PartialEq for Segment<O>
source§impl<O: PartialOrd + Offset> PartialOrd for Segment<O>
impl<O: PartialOrd + Offset> PartialOrd for Segment<O>
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 moreimpl<O: Copy + Offset> Copy for Segment<O>
impl<O: Eq + Offset> Eq for Segment<O>
impl<O: Offset> StructuralPartialEq for Segment<O>
Auto Trait Implementations§
impl<O> Freeze for Segment<O>where
O: Freeze,
impl<O> RefUnwindSafe for Segment<O>where
O: RefUnwindSafe,
impl<O> Send for Segment<O>where
O: Send,
impl<O> Sync for Segment<O>where
O: Sync,
impl<O> Unpin for Segment<O>where
O: Unpin,
impl<O> UnwindSafe for Segment<O>where
O: 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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.