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

source

pub fn equivalent(topo: &Topology, a: &Self, b: &Self) -> bool

The two arqs represent the same interval despite having potentially different terms

source

pub fn from_interval_rounded( topo: &Topology, power: u8, interval: DhtArcRange ) -> (Self, bool)

Return the ArqBounds which most closely matches the given DhtArcRange

source

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.

source

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

source

pub fn empty(topo: &Topology, power: u8) -> Self

An arbitrary zero-coverage arq.

source

pub fn segments(&self) -> impl Iterator<Item = SpaceSegment> + '_

Iterate over each segment (chunk) in the Arq

source

pub fn offset(&self) -> SpaceOffset

Get a reference to the arq bounds’s offset.

source§

impl<S: ArqStart> Arq<S>

source

pub fn to_ascii(&self, topo: &Topology, 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

source§

impl<S: ArqStart> Arq<S>

source

pub fn new(power: u8, start: S, count: SpaceOffset) -> Self

Constructor from individual parts

source

pub fn absolute_length(&self, topo: &Topology) -> u64

The absolute length of the entire arq.

source

pub fn to_dht_arc_range(&self, topo: &Topology) -> DhtArcRange

Convert to DhtArcRange

source

pub fn to_edge_locs(&self, topo: &Topology) -> (Loc, Loc)

Determine the edges of this Arq in absolute coordinates (Loc)

source

pub fn power(&self) -> u8

Accessor

source

pub fn count(&self) -> u32

Accessor

source

pub fn coverage(&self, topo: &Topology) -> f64

What portion of the whole circle does this arq cover?

source

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.

source

pub fn is_full(&self, topo: &Topology) -> bool

This arq has full coverage

source

pub fn is_empty(&self) -> bool

This arq has zero coverage

Trait Implementations§

source§

impl<S: Clone + ArqStart> Clone for Arq<S>

source§

fn clone(&self) -> Arq<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Debug + ArqStart> Debug for Arq<S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, S> Deserialize<'de> for Arq<S>where S: Deserialize<'de> + ArqStart,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&Arq<SpaceOffset>> for ArqBounds

source§

fn from(a: &ArqBounds) -> Self

Converts to this type from the input type.
source§

impl<S: PartialEq + ArqStart> PartialEq<Arq<S>> for Arq<S>

source§

fn eq(&self, other: &Arq<S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<S> Serialize for Arq<S>where S: Serialize + ArqStart,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<S: Copy + ArqStart> Copy for Arq<S>

source§

impl<S: Eq + ArqStart> Eq for Arq<S>

source§

impl<S: ArqStart> StructuralEq for Arq<S>

source§

impl<S: ArqStart> StructuralPartialEq for Arq<S>