pub struct ValueOverlay<T> { /* private fields */ }Expand description
A sparse overlay of rank ranges and values, used to assemble or
patch a [ValueMesh] without materializing per-rank data.
Unlike ValueMesh, which always represents a complete, gap-free
mapping over a [Region], a ValueOverlay is intentionally
partial: it may describe only the ranks that have changed. This
allows callers to build and merge small, incremental updates
efficiently, while preserving the ValueMesh invariants after
merge.
Invariants:
- Runs are sorted by
(start, end). - Runs are non-empty and non-overlapping.
- Adjacent runs with equal values are coalesced.
- Region bounds are validated when the overlay is merged, not on insert.
Note: serialization assumes identical pointer width between sender
and receiver, as Range<usize> is not portable across
architectures. TODO: introduce a wire‐stable run type.
Implementations§
Source§impl<T> ValueOverlay<T>
impl<T> ValueOverlay<T>
Source§impl<T: PartialEq> ValueOverlay<T>
impl<T: PartialEq> ValueOverlay<T>
Sourcepub fn push_run(
&mut self,
range: Range<usize>,
value: T,
) -> Result<(), BuildError>
pub fn push_run( &mut self, range: Range<usize>, value: T, ) -> Result<(), BuildError>
Adds a (range, value) run while maintaining the overlay
invariants.
Fast path:
- If
rangeis after the last run (last.end <= range.start), this is an O(1) append. If it touches the last run andvalueis equal, the two runs are coalesced by extendingend.
Slow path:
- If the input is unsorted or overlaps the last run, the method falls back to a full normalize (sort + coalesce + overlap check), making this call O(n log n) in the number of runs.
Errors:
- Returns
BuildError::EmptyRangeifrange.is_empty().
Notes & guidance:
- Use this for already-sorted, non-overlapping appends to get the cheap fast path.
- For bulk or unsorted inserts, prefer
ValueOverlay::try_from_runs(collect → sort → coalesce) to avoid repeated re-normalization. - Adjacent equal-value runs are coalesced automatically.
§Examples
let mut ov = ValueOverlay::new();
ov.push_run(0..3, 1).unwrap(); // append
ov.push_run(3..5, 1).unwrap(); // coalesces to (0..5, 1)
// Unsorted input triggers normalize (O(n log n)):
ov.push_run(1..2, 2).unwrap(); // re-sorts, checks overlaps, coalescesSourcepub fn try_from_runs<I>(runs: I) -> Result<Self, BuildError>
pub fn try_from_runs<I>(runs: I) -> Result<Self, BuildError>
Builds an overlay from arbitrary runs, validating structure and coalescing equal-adjacent.
Trait Implementations§
Source§impl<T: Clone> Clone for ValueOverlay<T>
impl<T: Clone> Clone for ValueOverlay<T>
Source§fn clone(&self) -> ValueOverlay<T>
fn clone(&self) -> ValueOverlay<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for ValueOverlay<T>
impl<T: Debug> Debug for ValueOverlay<T>
Source§impl<T: Default> Default for ValueOverlay<T>
impl<T: Default> Default for ValueOverlay<T>
Source§fn default() -> ValueOverlay<T>
fn default() -> ValueOverlay<T>
Source§impl<'de, T> Deserialize<'de> for ValueOverlay<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ValueOverlay<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: Named> Named for ValueOverlay<T>
impl<T: Named> Named for ValueOverlay<T>
Source§fn typename() -> &'static str
fn typename() -> &'static str
Source§fn typehash() -> u64
fn typehash() -> u64
Source§fn typeid() -> TypeId
fn typeid() -> TypeId
Source§fn port() -> u64
fn port() -> u64
Source§impl<T: PartialEq> PartialEq for ValueOverlay<T>
impl<T: PartialEq> PartialEq for ValueOverlay<T>
Source§impl<T> Serialize for ValueOverlay<T>where
T: Serialize,
impl<T> Serialize for ValueOverlay<T>where
T: Serialize,
impl<T: Eq> Eq for ValueOverlay<T>
impl<T> StructuralPartialEq for ValueOverlay<T>
Auto Trait Implementations§
impl<T> Freeze for ValueOverlay<T>
impl<T> RefUnwindSafe for ValueOverlay<T>where
T: RefUnwindSafe,
impl<T> Send for ValueOverlay<T>where
T: Send,
impl<T> Sync for ValueOverlay<T>where
T: Sync,
impl<T> Unpin for ValueOverlay<T>where
T: Unpin,
impl<T> UnwindSafe for ValueOverlay<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
Source§impl<T> Checkpointable for Twhere
T: RemoteMessage + Clone,
impl<T> Checkpointable for Twhere
T: RemoteMessage + Clone,
Source§type State = T
type State = T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more