Skip to main content

Section

Struct Section 

Source
pub struct Section<V, S: Storage<V>> { /* private fields */ }

Implementations§

Source§

impl<V, S> Section<V, S>
where S: Storage<V>,

Source

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.

Source

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.

Source

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

Source

pub fn iter(&self) -> impl Iterator<Item = (PointId, &[V])> + '_

Iterate over (PointId, &[V]) for all points in atlas order.

Source

pub fn as_flat_slice(&self) -> &[V]

Read-only view of the entire flat buffer in insertion order.

Source

pub fn for_each_in_order_mut<F>(&mut self, f: F)
where F: FnMut(PointId, &mut [V]),

Apply a closure to every (PointId, &mut [V]) in insertion order.

Source

pub fn for_each_in_order<F>(&self, f: F)
where F: FnMut(PointId, &[V]),

Read-only variant of [for_each_in_order_mut].

Source§

impl<V: Clone + Default, S: Storage<V>> Section<V, S>

Source

pub fn gather_in_order(&self) -> Vec<V>

Gather the entire section into a flat buffer in insertion order.

Source

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.

Source

pub fn try_remove_point(&mut self, p: PointId) -> Result<(), MeshSieveError>

Remove a point from the section, rebuilding data to keep slices contiguous.

§Errors

Returns Err(MissingSectionPoint) if a point is missing from the old atlas or data.

§Complexity

O(n) atlas reindex + O(total_len_new) data rebuild.

§Determinism

Deterministic rebuild in insertion order with no gaps.

Source

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_pointdst_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
Source

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.

Source

pub fn try_scatter_with_plan( &mut self, buf: &[V], plan: &ScatterPlan, ) -> Result<(), MeshSieveError>

Scatter using a precomputed plan; fails if the atlas has changed.

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

Source§

impl<V: Clone + Default, S: Storage<V> + Clone> Section<V, S>

Source

pub fn new(atlas: Atlas) -> Self

Construct a new Section given an existing Atlas.

Initializes the data buffer with V::default() repeated for each degree of freedom in the atlas.

§Complexity

O(total_len) to fill with V::default().

§Determinism

Initial layout matches the atlas’ insertion order deterministically.

Source

pub fn try_add_point( &mut self, p: PointId, len: usize, ) -> Result<(), MeshSieveError>

Add a new point to the section, resizing data as needed.

§Errors

Returns Err(AtlasInsertionFailed) if the atlas insertion fails.

§Complexity

O(n) atlas insertion (reindex) + O(total_len_new) data resize.

§Determinism

Data remains contiguous in insertion order; the new point is appended.

Source

pub fn with_atlas_mut<F>(&mut self, f: F) -> Result<(), MeshSieveError>
where F: FnOnce(&mut Atlas),

Safely mutate the atlas and rebuild data to remain consistent.

  • New points get len default-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_resize to 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.

Source

pub fn with_atlas_resize<F>( &mut self, policy: ResizePolicy<V>, f: F, ) -> Result<(), MeshSieveError>
where F: FnOnce(&mut Atlas),

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.

Source

pub fn try_scatter_in_order(&mut self, buf: &[V]) -> Result<(), MeshSieveError>

Scatter a flat buffer into the section in atlas insertion order.

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

Trait Implementations§

Source§

impl<V: Clone, S: Clone + Storage<V>> Clone for Section<V, S>

Source§

fn clone(&self) -> Section<V, S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug, S: Debug + Storage<V>> Debug for Section<V, S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<V, S> DebugInvariants for Section<V, S>
where S: Storage<V>,

Source§

fn debug_assert_invariants(&self)

Assert invariants in debug builds or when invariant checking is enabled.
Source§

fn validate_invariants(&self) -> Result<(), MeshSieveError>

Validate invariants and return the first error encountered.
Source§

impl<V, S> FallibleMap<V> for Section<V, S>
where S: Storage<V>,

Implement FallibleMap for Section<V>.

Source§

fn try_get(&self, p: PointId) -> Result<&[V], MeshSieveError>

Immutable access to p’s slice.
Source§

fn try_get_mut(&mut self, p: PointId) -> Result<&mut [V], MeshSieveError>

Mutable access to p’s slice.
Source§

impl<V, S: Storage<V>> InvalidateCache for Section<V, S>

Source§

fn invalidate_cache(&mut self)

Invalidate all internal caches so future queries recompute correctly.

Auto Trait Implementations§

§

impl<V, S> Freeze for Section<V, S>
where S: Freeze,

§

impl<V, S> RefUnwindSafe for Section<V, S>

§

impl<V, S> Send for Section<V, S>
where S: Send, V: Send,

§

impl<V, S> Sync for Section<V, S>
where S: Sync, V: Sync,

§

impl<V, S> Unpin for Section<V, S>
where S: Unpin, V: Unpin,

§

impl<V, S> UnsafeUnpin for Section<V, S>
where S: UnsafeUnpin,

§

impl<V, S> UnwindSafe for Section<V, S>
where S: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> AccumulatePathExt for T

Source§

fn accumulate_path<O, I>(path: I) -> O
where O: Orientation, I: IntoIterator<Item = O>,

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

impl<T> PayloadLike for T
where T: Clone,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.