pub struct Arq<S = DhtLocation>where
    S: ArqStart,{
    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§

§

impl<S> Arq<S>where S: ArqStart,

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

Constructor from individual parts

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

The absolute length of the entire arq.

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

Convert to DhtArcRange

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

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

pub fn power(&self) -> u8

Accessor

pub fn count(&self) -> u32

Accessor

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

What portion of the whole circle does this arq cover?

pub fn requantize(&self, new_power: u8) -> Option<Arq<S>>

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.

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

This arq has full coverage

pub fn is_empty(&self) -> bool

This arq has zero coverage

§

impl Arq

pub fn new_full(topo: &Topology, start: DhtLocation, power: u8) -> Arq

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

pub fn downshift(&self) -> Arq

Reduce the power by 1

pub fn upshift(&self, force: bool) -> Option<Arq>

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

pub fn to_bounds(&self, topo: &Topology) -> Arq<SpaceOffset>

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

pub fn start_loc(&self) -> DhtLocation

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

pub fn count_mut(&mut self) -> &mut u32

Get a mutable reference to the arq’s count.

pub fn to_dht_arc(&self, topo: &Topology) -> DhtArc

Convert to DhtArc

pub fn from_dht_arc_approximate( topo: &Topology, strat: &ArqStrat, dht_arc: &DhtArc ) -> Arq

Computes the Arq which most closely matches the given DhtArc

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

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

§

impl Arq<SpaceOffset>

pub fn equivalent( topo: &Topology, a: &Arq<SpaceOffset>, b: &Arq<SpaceOffset> ) -> bool

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

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

Return the ArqBounds which most closely matches the given DhtArcRange

pub fn from_interval( topo: &Topology, power: u8, interval: DhtArcRange ) -> Option<Arq<SpaceOffset>>

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

pub fn empty(topo: &Topology, power: u8) -> Arq<SpaceOffset>

An arbitrary zero-coverage arq.

pub fn segments(&self) -> impl Iterator<Item = Segment<SpaceOffset>>

Iterate over each segment (chunk) in the Arq

pub fn offset(&self) -> SpaceOffset

Get a reference to the arq bounds’s offset.

Trait Implementations§

§

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

§

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
§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

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

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

impl From<&Arq<SpaceOffset>> for Arq<SpaceOffset>

§

fn from(a: &Arq<SpaceOffset>) -> Arq<SpaceOffset>

Converts to this type from the input type.
§

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

§

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.
§

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

§

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

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

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

§

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

§

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

§

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

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Arq<S>where S: RefUnwindSafe,

§

impl<S> Send for Arq<S>where S: Send,

§

impl<S> Sync for Arq<S>where S: Sync,

§

impl<S> Unpin for Arq<S>where S: Unpin,

§

impl<S> UnwindSafe for Arq<S>where S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcastable for Twhere T: Any + Send + Sync + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq + Debug,