Type Alias kitsune_p2p_dht::arq::ArqBounds
source · pub type ArqBounds = Arq<SpaceOffset>;
Expand description
Alias for Arq with an SpaceOffset start
Aliased Type§
struct ArqBounds {
pub start: SpaceOffset,
pub power: u8,
pub count: SpaceOffset,
}
Fields§
§start: SpaceOffset
The “start” defines the left edge of the arq
power: u8
The level of quantization. Total length is 2^power * count
.
The power must be between 0 and 31, inclusive (power of 32 causes overflow)
count: SpaceOffset
The number of unit lengths. We never expect the count to be less than 4 or so, and not much larger than 32.
Implementations§
source§impl ArqBounds
impl ArqBounds
sourcepub fn equivalent(topo: &Topology, a: &Self, b: &Self) -> bool
pub fn equivalent(topo: &Topology, a: &Self, b: &Self) -> bool
The two arqs represent the same interval despite having potentially different terms
sourcepub fn from_interval_rounded(
topo: &Topology,
power: u8,
interval: DhtArcRange
) -> (Self, bool)
pub fn from_interval_rounded( topo: &Topology, power: u8, interval: DhtArcRange ) -> (Self, bool)
Return the ArqBounds which most closely matches the given DhtArcRange
sourcepub fn from_interval(
topo: &Topology,
power: u8,
interval: DhtArcRange
) -> Option<Self>
pub fn from_interval( topo: &Topology, power: u8, interval: DhtArcRange ) -> Option<Self>
Return the ArqBounds which is equivalent to the given DhtArcRange
if it exists.
sourcepub fn to_arq<F: FnOnce(Loc) -> Loc>(&self, topo: &Topology, f: F) -> Arq
pub fn to_arq<F: FnOnce(Loc) -> Loc>(&self, topo: &Topology, f: F) -> Arq
Upcast this ArqBounds to an Arq that has knowledge of its Loc
sourcepub fn segments(&self) -> impl Iterator<Item = SpaceSegment> + '_
pub fn segments(&self) -> impl Iterator<Item = SpaceSegment> + '_
Iterate over each segment (chunk) in the Arq
sourcepub fn offset(&self) -> SpaceOffset
pub fn offset(&self) -> SpaceOffset
Get a reference to the arq bounds’s offset.
source§impl<S: ArqStart> Arq<S>
impl<S: ArqStart> Arq<S>
sourcepub fn new(power: u8, start: S, count: SpaceOffset) -> Self
pub fn new(power: u8, start: S, count: SpaceOffset) -> Self
Constructor from individual parts
sourcepub fn absolute_length(&self, topo: &Topology) -> u64
pub fn absolute_length(&self, topo: &Topology) -> u64
The absolute length of the entire arq.
sourcepub fn to_dht_arc_range(&self, topo: &Topology) -> DhtArcRange
pub fn to_dht_arc_range(&self, topo: &Topology) -> DhtArcRange
Convert to DhtArcRange
sourcepub fn to_edge_locs(&self, topo: &Topology) -> (Loc, Loc)
pub fn to_edge_locs(&self, topo: &Topology) -> (Loc, Loc)
Determine the edges of this Arq in absolute coordinates (Loc
)
sourcepub fn coverage(&self, topo: &Topology) -> f64
pub fn coverage(&self, topo: &Topology) -> f64
What portion of the whole circle does this arq cover?
sourcepub fn requantize(&self, new_power: u8) -> Option<Self>
pub fn requantize(&self, new_power: u8) -> Option<Self>
Requantize to a different power. If requantizing to a higher power, only requantize if there is no information loss due to rounding. Otherwise, return None.