Trait pasture_core::containers::PerAttributePointBufferMut[][src]

pub trait PerAttributePointBufferMut<'b>: PerAttributePointBuffer {
    fn get_raw_attribute_mut(
        &mut self,
        point_index: usize,
        attribute: &PointAttributeDefinition
    ) -> &mut [u8];
fn get_raw_attribute_range_mut(
        &mut self,
        index_range: Range<usize>,
        attribute: &PointAttributeDefinition
    ) -> &mut [u8];
fn slice_mut(
        &'b mut self,
        range: Range<usize>
    ) -> PerAttributePointBufferSliceMut<'b>;
fn disjunct_slices_mut<'p>(
        &'p mut self,
        ranges: &[Range<usize>]
    ) -> Vec<PerAttributePointBufferSliceMut<'b>>
    where
        'b: 'p
;
fn as_per_attribute_point_buffer(&self) -> &dyn PerAttributePointBuffer; }

Trait for PerAttributePointBuffer types that provide mutable access to specific attributes

Required methods

fn get_raw_attribute_mut(
    &mut self,
    point_index: usize,
    attribute: &PointAttributeDefinition
) -> &mut [u8]
[src]

Mutable version of get_raw_attribute_ref

fn get_raw_attribute_range_mut(
    &mut self,
    index_range: Range<usize>,
    attribute: &PointAttributeDefinition
) -> &mut [u8]
[src]

Mutable version of get_raw_attribute_range_ref

fn slice_mut(
    &'b mut self,
    range: Range<usize>
) -> PerAttributePointBufferSliceMut<'b>
[src]

Returns a mutable slice of the associated PerAttributePointBufferMut

fn disjunct_slices_mut<'p>(
    &'p mut self,
    ranges: &[Range<usize>]
) -> Vec<PerAttributePointBufferSliceMut<'b>> where
    'b: 'p, 
[src]

Splits the associated PerAttributePointBufferMut into multiple disjoint mutable slices, based on the given disjoint ranges. This function is similar to Vec::split_as_mut, but can split into more than two regions.

Note

The lifetime bounds seem a bit weird for this function, but they are necessary. The lifetime of this 'b of this trait determines how long the underlying buffer (i.e. whatever stores the point data) lives. The lifetime 'p of this function enables nested slicing of buffers, because it is bounded to live at most as long as 'b. If 'b and 'p were a single lifetime, then it would require that any buffer reference from which we want to obtain a slice lives as long as the buffer itself. This is restrictive in a way that is not necessary. Consider the following scenario in pseudo-code, annotated with lifetimes:

'x: {
// Assume 'buffer' contains some data
let mut buffer : PerAttributeVecPointStorage = ...;
    'y: {
        // Obtain two slices to the lower and upper half of the buffer
        let mut half_slices = buffer.disjunct_slices_mut(&[0..(buffer.len()/2), (buffer.len()/2)..buffer.len()]);
        // ... do something with the slices ...
        'z: {
            // Split the half slices in half again
            let quarter_len = buffer.len() / 4;
            let half_len = buffer.len() / 2;
            let mut lower_quarter_slices = half_slices[0].disjunct_slices_mut(&[0..quarter_len, quarter_len..half_len]);
        }
    }
}

In this scenario, buffer lives for 'x, while half_slices only lives for 'y. The underlying data in half_slices however lives as long as buffer. The separate lifetime bound 'p on this function is what allows calling disjunct_slices_mut on half_slices[0], even though half_slices only lives for 'y.

Panics

If any two ranges in ranges overlap, or if any range in ranges is out of bounds

fn as_per_attribute_point_buffer(&self) -> &dyn PerAttributePointBuffer[src]

Helper method to access this PerAttributePointBufferMut as a PerAttributePointBuffer

Loading content...

Implementors

impl<'p> PerAttributePointBufferMut<'p> for PerAttributePointBufferSliceMut<'p>[src]

impl<'p> PerAttributePointBufferMut<'p> for PerAttributeVecPointStorage[src]

Loading content...