Enum kitsune_p2p_dht_arc::DhtArcRange
source · pub enum DhtArcRange<T = DhtLocation> {
Empty,
Full,
Bounded(T, T),
}
Expand description
A variant of DHT arc which is intentionally forgetful of the Agent’s location. This type is used in places where set logic (union and intersection) is performed on arcs, which splits and joins arcs in such a way that it doesn’t make sense to claim that the arc belongs to any particular agent or location.
This type exists to make sure we don’t accidentally intepret the starting point of such a “derived” arc as a legitimate agent location.
Variants§
Implementations§
source§impl<T: PartialOrd + Num> DhtArcRange<T>
impl<T: PartialOrd + Num> DhtArcRange<T>
source§impl<T> DhtArcRange<T>
impl<T> DhtArcRange<T>
pub fn map<U, F: Fn(T) -> U>(self, f: F) -> DhtArcRange<U>
source§impl<T: AsPrimitive<u32>> DhtArcRange<T>
impl<T: AsPrimitive<u32>> DhtArcRange<T>
pub fn from_bounds(start: T, end: T) -> DhtArcRange<DhtLocation>
pub fn from_start_and_len(start: T, len: u64) -> DhtArcRange<DhtLocation>
sourcepub fn from_start_and_half_len(
start: T,
half_len: u32
) -> DhtArcRange<DhtLocation>
pub fn from_start_and_half_len( start: T, half_len: u32 ) -> DhtArcRange<DhtLocation>
Convenience for our legacy code which defined arcs in terms of half-lengths rather than full lengths
pub fn new_generic(start: T, end: T) -> Self
source§impl DhtArcRange<u32>
impl DhtArcRange<u32>
pub fn canonical(self) -> DhtArcRange
source§impl DhtArcRange<DhtLocation>
impl DhtArcRange<DhtLocation>
sourcepub fn to_bounds_grouped(&self) -> Option<(DhtLocation, DhtLocation)>
pub fn to_bounds_grouped(&self) -> Option<(DhtLocation, DhtLocation)>
Represent an arc as an optional range of inclusive endpoints. If none, the arc length is 0
sourcepub fn to_primitive_bounds_detached(&self) -> (Option<u32>, Option<u32>)
pub fn to_primitive_bounds_detached(&self) -> (Option<u32>, Option<u32>)
Same as to_bounds_grouped, but with the return type “inside-out”
sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Check if this arc is bounded.
sourcepub fn overlap_coverage(&self, other: &Self) -> f64
pub fn overlap_coverage(&self, other: &Self) -> f64
Amount of intersection between two arcs
pub fn length(&self) -> u64
pub fn half_length(&self) -> u32
sourcepub fn to_ascii(&self, len: usize) -> String
pub fn to_ascii(&self, len: usize) -> String
Handy ascii representation of an arc, especially useful when looking at several arcs at once to get a sense of their overlap
pub fn canonical(self) -> DhtArcRange
Trait Implementations§
source§impl<T: Clone> Clone for DhtArcRange<T>
impl<T: Clone> Clone for DhtArcRange<T>
source§fn clone(&self) -> DhtArcRange<T>
fn clone(&self) -> DhtArcRange<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for DhtArcRange<T>
impl<T: Debug> Debug for DhtArcRange<T>
source§impl<'de, T> Deserialize<'de> for DhtArcRange<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for DhtArcRange<T>where T: Deserialize<'de>,
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>,
source§impl From<&DhtArc> for DhtArcRange
impl From<&DhtArc> for DhtArcRange
source§impl From<&DhtArcRange<DhtLocation>> for DhtArcSet
impl From<&DhtArcRange<DhtLocation>> for DhtArcSet
source§fn from(arc: &DhtArcRange) -> Self
fn from(arc: &DhtArcRange) -> Self
source§impl From<DhtArc> for DhtArcRange
impl From<DhtArc> for DhtArcRange
source§impl From<DhtArcRange<DhtLocation>> for DhtArcSet
impl From<DhtArcRange<DhtLocation>> for DhtArcSet
source§fn from(arc: DhtArcRange) -> Self
fn from(arc: DhtArcRange) -> Self
source§impl<T: Hash> Hash for DhtArcRange<T>
impl<T: Hash> Hash for DhtArcRange<T>
source§impl<T: PartialEq> PartialEq<DhtArcRange<T>> for DhtArcRange<T>
impl<T: PartialEq> PartialEq<DhtArcRange<T>> for DhtArcRange<T>
source§fn eq(&self, other: &DhtArcRange<T>) -> bool
fn eq(&self, other: &DhtArcRange<T>) -> bool
self
and other
values to be equal, and is used
by ==
.