Struct kitsune_p2p_dht_arc::DhtArc
source · pub struct DhtArc(_, _);
Expand description
The main DHT arc type. Represents an Agent’s storage Arc on the DHT,
preserving the agent’s DhtLocation even in the case of a Full or Empty arc.
Contrast to DhtArcRange
, which is used for cases where the arc is not
associated with any particular Agent, and so the agent’s Location cannot be known.
Implementations§
source§impl DhtArc
impl DhtArc
pub fn bounded(a: DhtArcRange) -> Self
pub fn empty(loc: DhtLocation) -> Self
pub fn full(loc: DhtLocation) -> Self
pub fn start_loc(&self) -> DhtLocation
pub fn inner(self) -> DhtArcRange
sourcepub fn from_parts(a: DhtArcRange, loc: DhtLocation) -> Self
pub fn from_parts(a: DhtArcRange, loc: DhtLocation) -> Self
Construct from an arc range and a location. The location is only used if the arc range is full or empty.
pub fn from_start_and_half_len<L: Into<DhtLocation>>( start: L, half_len: u32 ) -> Self
pub fn from_start_and_len<L: Into<DhtLocation>>(start: L, len: u64) -> Self
pub fn from_bounds<L: Into<DhtLocation>>(start: L, end: L) -> Self
pub fn update_length(&mut self, new_length: u64)
pub fn to_ascii(&self, len: usize) -> String
Methods from Deref<Target = DhtArcRange>§
pub fn contains<B: Borrow<T>>(&self, t: B) -> bool
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 dist(&self, tgt: u32) -> u32
pub fn dist(&self, tgt: u32) -> u32
Get the min distance to a location. Zero if Full, u32::MAX if Empty.
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