pub struct Arq<S: ArqStart = Loc> {
    pub start: S,
    pub power: u8,
    pub count: SpaceOffset,
}
Expand description

A quantized DHT arc.

Coordinates

Arq coordinates are expressed in terms of powers-of-two, representing the “chunk” or “segment” size to work with. The chunk size is determined by the Topology of the space it is in, as well as the power of the Arq. The actual chunk size is given by:

chunk size = topology.space.quantum * 2^power

So, the power represents the amount of quantization on top of the quantum size set by the Topology, not the total quantization level.

The start is generic, because there are actually two flavors of Arq:

  • one which has a definite starting DhtLocation associated with it,
  • and one which does not.

The first flavor is used to represent Arqs which belong to Agents. It’s important to record the actual absolute Location of the Arq, because the exact location determines the starting Chunk when requantizing to higher and lower levels.

The second flavor is mainly used to represent the intersections and unions of Arqs. In this case, there is no definite location associated, so we want to forget about the original Location data associated with each Arq.

Fields

start: S

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

Handy ascii representation of an arc, especially useful when looking at several arcs at once to get a sense of their overlap

Constructor from individual parts

The absolute length of the entire arq.

Convert to DhtArcRange

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

Accessor

Accessor

What portion of the whole circle does this arq cover?

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.

This arq has full coverage

This arq has zero coverage

Construct a full arq at the given power. The count is calculated accordingly.

Reduce the power by 1

Increase the power by 1. If this results in rounding, return None, unless force is true, in which case always return Some.

Convert to the ArqBounds representation, which forgets about the Loc associated with this arq.

Get a reference to the arq’s left edge in absolute coordinates.

Get a mutable reference to the arq’s count.

Convert to DhtArc

Computes the Arq which most closely matches the given DhtArc

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

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

Return the ArqBounds which most closely matches the given DhtArcRange

Return the ArqBounds which is equivalent to the given DhtArcRange if it exists.

Upcast this ArqBounds to an Arq that has knowledge of its Loc

An arbitrary zero-coverage arq.

Iterate over each segment (chunk) in the Arq

Get a reference to the arq bounds’s offset.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
Performance hack: Clone doesn’t get inlined for Copy types in debug mode, so make it inline anyway.
Tests if Self the same as the type T Read more
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more