pub trait BorrowedMutBufferExt<'a>: BorrowedMutBuffer<'a> {
// Provided methods
fn view_mut<'b, T: PointType>(&'b mut self) -> PointViewMut<'a, 'b, Self, T>
where 'a: 'b { ... }
fn view_attribute_mut<'b, T: PrimitiveType>(
&'b mut self,
attribute: &PointAttributeDefinition,
) -> AttributeViewMut<'a, 'b, Self, T>
where 'a: 'b { ... }
fn transform_attribute<'b, T: PrimitiveType, F: Fn(usize, T) -> T>(
&'b mut self,
attribute: &PointAttributeDefinition,
func: F,
)
where 'a: 'b { ... }
}Expand description
Extension trait for BorrowedMutBuffer that allows obtaining strongly-typed views over points and
attributes.
Provided Methods§
Sourcefn view_mut<'b, T: PointType>(&'b mut self) -> PointViewMut<'a, 'b, Self, T>where
'a: 'b,
fn view_mut<'b, T: PointType>(&'b mut self) -> PointViewMut<'a, 'b, Self, T>where
'a: 'b,
Get a strongly typed view of the point data of this buffer. This view allows mutating the point data!
§Panics
If T::point_layout() does not match self.point_layout()
Sourcefn view_attribute_mut<'b, T: PrimitiveType>(
&'b mut self,
attribute: &PointAttributeDefinition,
) -> AttributeViewMut<'a, 'b, Self, T>where
'a: 'b,
fn view_attribute_mut<'b, T: PrimitiveType>(
&'b mut self,
attribute: &PointAttributeDefinition,
) -> AttributeViewMut<'a, 'b, Self, T>where
'a: 'b,
Get a strongly typed view of the attribute of all points in this buffer. This view allows mutating
the attribute data!
§Panics
If attribute is not part of the PointLayout of this buffer.
If T::data_type() does not match attribute.datatype()
Sourcefn transform_attribute<'b, T: PrimitiveType, F: Fn(usize, T) -> T>(
&'b mut self,
attribute: &PointAttributeDefinition,
func: F,
)where
'a: 'b,
fn transform_attribute<'b, T: PrimitiveType, F: Fn(usize, T) -> T>(
&'b mut self,
attribute: &PointAttributeDefinition,
func: F,
)where
'a: 'b,
Apply a transformation function to the given attribute of all points within this buffer. This function is
helpful if you want to modify a single attribute of a buffer in-place and works for buffers of all memory
layouts. For columnar buffers, prefer using get_attribute_range_mut to modify attribute data in-place.
This function does not support attribute type conversion, so the type T must match the PointAttributeDataType
of attribute!
The conversion function takes the current value of the attribute as a strongly typed T and returns the new value
for the attribute. It also takes the index of the point within the buffer, so that func can access additional
data.
§Panics
If attribute is not part of the PointLayout of this buffer.
If T::data_type() does not equal attribute.datatype()
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.