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
Empty
Full
Bounded(T, T)
Implementations
sourceimpl<T: PartialOrd + Num> DhtArcRange<T>
impl<T: PartialOrd + Num> DhtArcRange<T>
sourceimpl<T> DhtArcRange<T>
impl<T> DhtArcRange<T>
sourceimpl<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
sourceimpl DhtArcRange<u32>
impl DhtArcRange<u32>
pub fn canonical(self) -> DhtArcRange
sourceimpl 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
sourceimpl<T: Clone> Clone for DhtArcRange<T>
impl<T: Clone> Clone for DhtArcRange<T>
sourcefn clone(&self) -> DhtArcRange<T>
fn clone(&self) -> DhtArcRange<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for DhtArcRange<T>
impl<T: Debug> Debug for DhtArcRange<T>
sourceimpl<'de, T> Deserialize<'de> for DhtArcRange<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for DhtArcRange<T> where
T: Deserialize<'de>,
sourcefn 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
sourceimpl From<&DhtArc> for DhtArcRange
impl From<&DhtArc> for DhtArcRange
sourceimpl From<&DhtArcRange<DhtLocation>> for DhtArcSet
impl From<&DhtArcRange<DhtLocation>> for DhtArcSet
sourcefn from(arc: &DhtArcRange) -> Self
fn from(arc: &DhtArcRange) -> Self
Converts to this type from the input type.
sourceimpl From<DhtArc> for DhtArcRange
impl From<DhtArc> for DhtArcRange
sourceimpl From<DhtArcRange<DhtLocation>> for DhtArcSet
impl From<DhtArcRange<DhtLocation>> for DhtArcSet
sourcefn from(arc: DhtArcRange) -> Self
fn from(arc: DhtArcRange) -> Self
Converts to this type from the input type.
sourceimpl<T: Hash> Hash for DhtArcRange<T>
impl<T: Hash> Hash for DhtArcRange<T>
sourceimpl<T: PartialEq> PartialEq<DhtArcRange<T>> for DhtArcRange<T>
impl<T: PartialEq> PartialEq<DhtArcRange<T>> for DhtArcRange<T>
sourcefn eq(&self, other: &DhtArcRange<T>) -> bool
fn eq(&self, other: &DhtArcRange<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &DhtArcRange<T>) -> bool
fn ne(&self, other: &DhtArcRange<T>) -> bool
This method tests for !=
.
sourceimpl<T> Serialize for DhtArcRange<T> where
T: Serialize,
impl<T> Serialize for DhtArcRange<T> where
T: Serialize,
impl<T: Copy> Copy for DhtArcRange<T>
impl<T: Eq> Eq for DhtArcRange<T>
impl<T> StructuralEq for DhtArcRange<T>
impl<T> StructuralPartialEq for DhtArcRange<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for DhtArcRange<T> where
T: RefUnwindSafe,
impl<T> Send for DhtArcRange<T> where
T: Send,
impl<T> Sync for DhtArcRange<T> where
T: Sync,
impl<T> Unpin for DhtArcRange<T> where
T: Unpin,
impl<T> UnwindSafe for DhtArcRange<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more