pub struct Section<V, S: Storage<V>> { /* private fields */ }Implementations§
Source§impl<V, S> Section<V, S>where
S: Storage<V>,
impl<V, S> Section<V, S>where
S: Storage<V>,
Sourcepub fn try_restrict(&self, p: PointId) -> Result<&[V], MeshSieveError>
pub fn try_restrict(&self, p: PointId) -> Result<&[V], MeshSieveError>
Read-only view of the data slice for a given point p.
§Errors
Returns Err(PointNotInAtlas(p)) if the point is not registered in the atlas,
or Err(MissingSectionPoint(p)) if the data buffer is inconsistent.
Sourcepub fn try_restrict_mut(
&mut self,
p: PointId,
) -> Result<&mut [V], MeshSieveError>
pub fn try_restrict_mut( &mut self, p: PointId, ) -> Result<&mut [V], MeshSieveError>
Mutable view of the data slice for a given point p.
§Errors
Returns Err(PointNotInAtlas(p)) if the point is not registered in the atlas,
or Err(MissingSectionPoint(p)) if the data buffer is inconsistent.
Sourcepub fn atlas(&self) -> &Atlas
pub fn atlas(&self) -> &Atlas
Read-only handle to the backing atlas.
Mutations must go through with_atlas_mut
to keep Section and its data buffer consistent.
§Complexity
O(1).
Sourcepub fn iter(&self) -> impl Iterator<Item = (PointId, &[V])> + '_
pub fn iter(&self) -> impl Iterator<Item = (PointId, &[V])> + '_
Iterate over (PointId, &[V]) for all points in atlas order.
Sourcepub fn as_flat_slice(&self) -> &[V]
pub fn as_flat_slice(&self) -> &[V]
Read-only view of the entire flat buffer in insertion order.
Sourcepub fn for_each_in_order_mut<F>(&mut self, f: F)
pub fn for_each_in_order_mut<F>(&mut self, f: F)
Apply a closure to every (PointId, &mut [V]) in insertion order.
Sourcepub fn for_each_in_order<F>(&self, f: F)
pub fn for_each_in_order<F>(&self, f: F)
Read-only variant of [for_each_in_order_mut].
Source§impl<V: Clone + Default, S: Storage<V>> Section<V, S>
impl<V: Clone + Default, S: Storage<V>> Section<V, S>
Sourcepub fn gather_in_order(&self) -> Vec<V>
pub fn gather_in_order(&self) -> Vec<V>
Gather the entire section into a flat buffer in insertion order.
Sourcepub fn try_set(&mut self, p: PointId, val: &[V]) -> Result<(), MeshSieveError>
pub fn try_set(&mut self, p: PointId, val: &[V]) -> Result<(), MeshSieveError>
Overwrite the data slice at point p with the values in val.
§Errors
Returns Err(PointNotInAtlas(p)) if the point is not registered in the atlas,
or Err(SliceLengthMismatch) if the input slice length does not match the expected length.
Sourcepub fn try_remove_point(&mut self, p: PointId) -> Result<(), MeshSieveError>
pub fn try_remove_point(&mut self, p: PointId) -> Result<(), MeshSieveError>
Sourcepub fn try_apply_delta_between_points<D: SliceDelta<V>>(
&mut self,
src_point: PointId,
dst_point: PointId,
delta: &D,
) -> Result<(), MeshSieveError>
pub fn try_apply_delta_between_points<D: SliceDelta<V>>( &mut self, src_point: PointId, dst_point: PointId, delta: &D, ) -> Result<(), MeshSieveError>
Apply a delta from src_point → dst_point directly within the section buffer.
In debug builds or when the strict-invariants feature (or alias check-invariants) is enabled, section
invariants are validated before and after applying the delta. Violations
panic prior to any slicing.
If the underlying slices do not overlap, the delta is applied without any additional allocation. Otherwise, the source slice is first copied into a temporary buffer to maintain aliasing safety.
§Errors
MeshSieveError::PointNotInAtlasif either point is missing.MeshSieveError::SliceLengthMismatchif the slice lengths differ.MeshSieveError::MissingSectionPointif either slice is out of bounds.MeshSieveError::ScatterChunkMismatchif an offset/length overflows.
Sourcepub fn try_scatter_from(
&mut self,
other: &[V],
atlas_map: &[(usize, usize)],
) -> Result<(), MeshSieveError>
pub fn try_scatter_from( &mut self, other: &[V], atlas_map: &[(usize, usize)], ) -> Result<(), MeshSieveError>
Scatter values from an external buffer other into this section.
§Errors
Returns Err(ScatterLengthMismatch) if the input length does not match expected,
or Err(ScatterChunkMismatch) if a chunk is out of bounds.
§Complexity
O(total_len) to copy slices; validates bounds in O(n) where n is points.
§Determinism
Deterministic copy; *_with_plan additionally validates the plan version for safety.
Sourcepub fn try_scatter_with_plan(
&mut self,
buf: &[V],
plan: &ScatterPlan,
) -> Result<(), MeshSieveError>
pub fn try_scatter_with_plan( &mut self, buf: &[V], plan: &ScatterPlan, ) -> Result<(), MeshSieveError>
Source§impl<V: Clone + Default, S: Storage<V> + Clone> Section<V, S>
impl<V: Clone + Default, S: Storage<V> + Clone> Section<V, S>
Sourcepub fn try_add_point(
&mut self,
p: PointId,
len: usize,
) -> Result<(), MeshSieveError>
pub fn try_add_point( &mut self, p: PointId, len: usize, ) -> Result<(), MeshSieveError>
Sourcepub fn with_atlas_mut<F>(&mut self, f: F) -> Result<(), MeshSieveError>
pub fn with_atlas_mut<F>(&mut self, f: F) -> Result<(), MeshSieveError>
Safely mutate the atlas and rebuild data to remain consistent.
- New points get
lendefault-initialized values. - Removed points drop data.
- Reordered/retuned points keep their old values (by
PointId), copied into the new contiguous layout. - Length changes for existing points are rejected. Use
with_atlas_resizeto allow slice length changes with an explicit policy.
§Errors
Returns MeshSieveError::AtlasPointLengthChanged if any existing
point’s slice length differs after mutation.
§Complexity
O(n) mapping + O(total_len_new) copy/initialize.
§Determinism
Rebuild order follows atlas insertion order deterministically.
Sourcepub fn with_atlas_resize<F>(
&mut self,
policy: ResizePolicy<V>,
f: F,
) -> Result<(), MeshSieveError>
pub fn with_atlas_resize<F>( &mut self, policy: ResizePolicy<V>, f: F, ) -> Result<(), MeshSieveError>
Mutate the atlas, allowing slice length changes per policy.
Existing points preserve or initialize values according to policy.
New points are initialized per policy as well. Removed points drop
their data. On error, the atlas and data are rolled back to their
original state.
Sourcepub fn try_scatter_in_order(&mut self, buf: &[V]) -> Result<(), MeshSieveError>
pub fn try_scatter_in_order(&mut self, buf: &[V]) -> Result<(), MeshSieveError>
Trait Implementations§
Source§impl<V, S> DebugInvariants for Section<V, S>where
S: Storage<V>,
impl<V, S> DebugInvariants for Section<V, S>where
S: Storage<V>,
Source§fn debug_assert_invariants(&self)
fn debug_assert_invariants(&self)
Source§fn validate_invariants(&self) -> Result<(), MeshSieveError>
fn validate_invariants(&self) -> Result<(), MeshSieveError>
Source§impl<V, S> FallibleMap<V> for Section<V, S>where
S: Storage<V>,
Implement FallibleMap for Section<V>.
impl<V, S> FallibleMap<V> for Section<V, S>where
S: Storage<V>,
Implement FallibleMap for Section<V>.
Source§fn try_get_mut(&mut self, p: PointId) -> Result<&mut [V], MeshSieveError>
fn try_get_mut(&mut self, p: PointId) -> Result<&mut [V], MeshSieveError>
p’s slice.