pub struct ViewMap { /* private fields */ }Expand description
A set of zero-copy view → source aliasing relationships.
Each entry means “view owns no activation slot; its bytes live inside
source’s buffer”. A view of a view is allowed; ViewMap::root folds a
chain down to the single real buffer owner.
Implementations§
Source§impl ViewMap
impl ViewMap
Sourcepub fn from_pairs(pairs: impl IntoIterator<Item = (ValueId, ValueId)>) -> Self
pub fn from_pairs(pairs: impl IntoIterator<Item = (ValueId, ValueId)>) -> Self
Build a map from (view, source) pairs.
Sourcepub fn insert(&mut self, view: ValueId, source: ValueId)
pub fn insert(&mut self, view: ValueId, source: ValueId)
Record that view aliases source (owns no buffer of its own).
Sourcepub fn is_view(&self, value: ValueId) -> bool
pub fn is_view(&self, value: ValueId) -> bool
Whether value is a zero-copy view (aliases another value’s buffer and
therefore gets no slot of its own).
Sourcepub fn source_of(&self, value: ValueId) -> Option<ValueId>
pub fn source_of(&self, value: ValueId) -> Option<ValueId>
The immediate source value aliases, if it is a view.
Sourcepub fn root(&self, value: ValueId) -> ValueId
pub fn root(&self, value: ValueId) -> ValueId
Fold value to the root buffer owner by following view → source
edges transitively. Returns value itself when it is not a view.
A cycle in the (malformed) view map is broken defensively: the last node visited before the cycle closes is returned rather than looping forever.