Struct holochain::prelude::dependencies::kitsune_p2p_types::dht::arq::Arq
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,
impl<S> Arq<S>where S: ArqStart,
pub fn new(power: u8, start: S, count: SpaceOffset) -> Arq<S>
pub fn new(power: u8, start: S, count: SpaceOffset) -> Arq<S>
Constructor from individual parts
pub fn absolute_length(&self, topo: &Topology) -> u64
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<DhtLocation>
pub fn to_dht_arc_range(&self, topo: &Topology) -> DhtArcRange<DhtLocation>
Convert to DhtArcRange
pub fn to_edge_locs(&self, topo: &Topology) -> (DhtLocation, DhtLocation)
pub fn to_edge_locs(&self, topo: &Topology) -> (DhtLocation, DhtLocation)
Determine the edges of this Arq in absolute coordinates (Loc
)
pub fn requantize(&self, new_power: u8) -> Option<Arq<S>>
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.
§impl Arq<DhtLocation>
impl Arq<DhtLocation>
pub fn new_full(
topo: &Topology,
start: DhtLocation,
power: u8
) -> Arq<DhtLocation>
pub fn new_full( topo: &Topology, start: DhtLocation, power: u8 ) -> Arq<DhtLocation>
Construct a full arq at the given power.
The count
is calculated accordingly.
pub fn downshift(&self) -> Arq<DhtLocation>
pub fn downshift(&self) -> Arq<DhtLocation>
Reduce the power by 1
pub fn upshift(&self, force: bool) -> Option<Arq<DhtLocation>>
pub fn upshift(&self, force: bool) -> Option<Arq<DhtLocation>>
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>
pub fn to_bounds(&self, topo: &Topology) -> Arq<SpaceOffset>
pub fn start_loc(&self) -> DhtLocation
pub fn start_loc(&self) -> DhtLocation
Get a reference to the arq’s left edge in absolute coordinates.
pub fn to_dht_arc(&self, topo: &Topology) -> DhtArc
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<DhtLocation>
pub fn from_dht_arc_approximate( topo: &Topology, strat: &ArqStrat, dht_arc: &DhtArc ) -> Arq<DhtLocation>
Computes the Arq which most closely matches the given DhtArc
pub fn equivalent(
topo: &Topology,
a: &Arq<DhtLocation>,
b: &Arq<DhtLocation>
) -> bool
pub fn equivalent( topo: &Topology, a: &Arq<DhtLocation>, b: &Arq<DhtLocation> ) -> bool
The two arqs represent the same interval despite having potentially different terms
§impl Arq<SpaceOffset>
impl Arq<SpaceOffset>
pub fn equivalent(
topo: &Topology,
a: &Arq<SpaceOffset>,
b: &Arq<SpaceOffset>
) -> bool
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<DhtLocation>
) -> (Arq<SpaceOffset>, bool)
pub fn from_interval_rounded( topo: &Topology, power: u8, interval: DhtArcRange<DhtLocation> ) -> (Arq<SpaceOffset>, bool)
Return the ArqBounds which most closely matches the given DhtArcRange
pub fn from_interval(
topo: &Topology,
power: u8,
interval: DhtArcRange<DhtLocation>
) -> Option<Arq<SpaceOffset>>
pub fn from_interval( topo: &Topology, power: u8, interval: DhtArcRange<DhtLocation> ) -> Option<Arq<SpaceOffset>>
Return the ArqBounds which is equivalent to the given DhtArcRange
if it exists.
pub fn to_arq<F>(&self, topo: &Topology, f: F) -> Arq<DhtLocation>where
F: FnOnce(DhtLocation) -> DhtLocation,
pub fn to_arq<F>(&self, topo: &Topology, f: F) -> Arq<DhtLocation>where F: FnOnce(DhtLocation) -> DhtLocation,
Upcast this ArqBounds to an Arq that has knowledge of its Loc
pub fn empty(topo: &Topology, power: u8) -> Arq<SpaceOffset>
pub fn empty(topo: &Topology, power: u8) -> Arq<SpaceOffset>
An arbitrary zero-coverage arq.
pub fn segments(&self) -> impl Iterator<Item = Segment<SpaceOffset>>
pub fn segments(&self) -> impl Iterator<Item = Segment<SpaceOffset>>
Iterate over each segment (chunk) in the Arq
pub fn offset(&self) -> SpaceOffset
pub fn offset(&self) -> SpaceOffset
Get a reference to the arq bounds’s offset.
Trait Implementations§
§impl<'de, S> Deserialize<'de> for Arq<S>where
S: ArqStart + Deserialize<'de>,
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>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Arq<S>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
§impl From<&Arq<SpaceOffset>> for Arq<SpaceOffset>
impl From<&Arq<SpaceOffset>> for Arq<SpaceOffset>
§fn from(a: &Arq<SpaceOffset>) -> Arq<SpaceOffset>
fn from(a: &Arq<SpaceOffset>) -> Arq<SpaceOffset>
§impl<S> Serialize for Arq<S>where
S: ArqStart + Serialize,
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,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
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>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.