Struct kitsune_p2p_dht_arc::DhtArc
source · [−]pub struct DhtArc { /* private fields */ }
Expand description
Represents how much of a dht arc is held center_loc is where the hash is. The center_loc is the center of the arc The half length is the length of items held from the center in both directions half_length 0 means nothing is held half_length 1 means just the center_loc is held half_length n where n > 1 will hold those positions out half_length u32::MAX / 2 + 1 covers all positions on either side of center_loc. Imagine an bidirectional array:
[4][3][2][1][0][1][2][3][4]
[2][1][0][1][2]
Implementations
sourceimpl DhtArc
impl DhtArc
sourcepub fn new<I: Into<DhtLocation>>(center_loc: I, half_length: u32) -> Self
pub fn new<I: Into<DhtLocation>>(center_loc: I, half_length: u32) -> Self
Create an Arc from a hash location plus a length on either side half length is (0..(u32::Max / 2 + 1))
sourcepub fn full<I: Into<DhtLocation>>(center_loc: I) -> Self
pub fn full<I: Into<DhtLocation>>(center_loc: I) -> Self
Create a full arc from a center location
sourcepub fn empty<I: Into<DhtLocation>>(center_loc: I) -> Self
pub fn empty<I: Into<DhtLocation>>(center_loc: I) -> Self
Create an empty arc from a center location
sourcepub fn update_length(&mut self, density: PeerDensity)
pub fn update_length(&mut self, density: PeerDensity)
Update the half length based on a density reading. This will converge on a new target instead of jumping directly to the new target and is designed to be called at a given rate with more recent peer density readings.
sourcepub fn contains<I: Into<DhtLocation>>(&self, other_location: I) -> bool
pub fn contains<I: Into<DhtLocation>>(&self, other_location: I) -> bool
Check if a location is contained in this arc
pub fn interval(&self) -> ArcInterval
sourcepub fn primitive_range_grouped(&self) -> Option<(u32, u32)>
pub fn primitive_range_grouped(&self) -> Option<(u32, u32)>
Represent an arc as an optional range of inclusive endpoints. If none, the arc length is 0
sourcepub fn primitive_range_detached(&self) -> (Option<u32>, Option<u32>)
pub fn primitive_range_detached(&self) -> (Option<u32>, Option<u32>)
Same as primitive_range, but with the return type “inside-out”
sourcepub fn absolute_length(&self) -> u64
pub fn absolute_length(&self) -> u64
The absolute length that this arc will hold.
sourcepub fn half_length(&self) -> u32
pub fn half_length(&self) -> u32
Get the half length of this arc.
sourcepub fn center_loc(&self) -> DhtLocation
pub fn center_loc(&self) -> DhtLocation
Get the center location of this arc.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for DhtArc
impl<'de> Deserialize<'de> for DhtArc
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
impl Copy for DhtArc
impl Eq for DhtArc
impl StructuralEq for DhtArc
impl StructuralPartialEq for DhtArc
Auto Trait Implementations
impl RefUnwindSafe for DhtArc
impl Send for DhtArc
impl Sync for DhtArc
impl Unpin for DhtArc
impl UnwindSafe for DhtArc
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more