Struct BufferSliceMut

Source
pub struct BufferSliceMut<'a, T: BorrowedMutBuffer<'a> + ?Sized> { /* private fields */ }
Expand description

A mutable slice to a point buffer. Works like BufferSlice, but allows mutable access to the underlying buffer. This type conditionally implements the InterleavedBufferMut and ColumnarBufferMut traits if T implements them

Implementations§

Source§

impl<'a, T: BorrowedMutBuffer<'a> + ?Sized> BufferSliceMut<'a, T>

Source

pub fn new(buffer: &'a mut T, point_range: Range<usize>) -> Self

Creates a new BufferSliceMut for the given point_range in the given buffer

Trait Implementations§

Source§

impl<'a, T: BorrowedMutBuffer<'a> + ?Sized> BorrowedBuffer<'a> for BufferSliceMut<'a, T>

Source§

fn len(&self) -> usize

Returns the length of this buffer, i.e. the number of points Read more
Source§

fn point_layout(&self) -> &PointLayout

Returns the PointLayout of this buffer. The PointLayout describes the structure of a single point at runtime. Read more
Source§

fn get_point(&self, index: usize, data: &mut [u8])

Writes the data for the point at index from this buffer into data Read more
Source§

fn get_point_range(&self, range: Range<usize>, data: &mut [u8])

Writes the data for the given range of points from this buffer into data Read more
Source§

fn get_attribute( &self, attribute: &PointAttributeDefinition, index: usize, data: &mut [u8], )

Writes the data for the given attribute of the point at index into data Read more
Source§

unsafe fn get_attribute_unchecked( &self, attribute_member: &PointAttributeMember, index: usize, data: &mut [u8], )

Like get_attribute, but performs no check whether the attribute actually is part of this buffers PointLayout or not. Because of this, this function accepts a PointAttributeMember instead of a PointAttributeDefinition, and this PointAttributeMember must come from the PointLayout of this buffer! The benefit over get_attribute is that this function skips the include checks and thus will be faster if you repeatedly want to get data for a single attribute Read more
Source§

fn is_empty(&self) -> bool

Returns true if this buffer does not store any points Read more
Source§

fn get_attribute_range( &self, attribute: &PointAttributeDefinition, point_range: Range<usize>, data: &mut [u8], )

Writes the data for the given attribute of the given range of points into data. The attribute data will be tightly packed in data, irregardless of the memory layout of this buffer. The attribute values might not be correctly aligned, if the alignment requirement of attribute.datatype() is larger than the size of the attribute. All of the built-in attributes in pasture have alignments that are less than or equal to their size, so for built-in attributes you can assume that the attributes in data are correctly aligned. Read more
Source§

fn as_interleaved(&self) -> Option<&dyn InterleavedBuffer<'a>>

Try to get a reference to self as an InterleavedBuffer. Returns None if self does not implement InterleavedBuffer
Source§

fn as_columnar(&self) -> Option<&dyn ColumnarBuffer<'a>>

Try to get a reference to self as a ColumnarBuffer. Returns None if self does not implement ColumnarBuffer
Source§

impl<'a, T: BorrowedMutBuffer<'a> + ?Sized> BorrowedMutBuffer<'a> for BufferSliceMut<'a, T>

Source§

unsafe fn set_point(&mut self, index: usize, point_data: &[u8])

Sets the data for the point at the given index Read more
Source§

unsafe fn set_attribute( &mut self, attribute: &PointAttributeDefinition, index: usize, attribute_data: &[u8], )

Sets the data for the given attribute of the point at index Read more
Source§

fn swap(&mut self, from_index: usize, to_index: usize)

Swaps the two points at from_index and to_index. Implementations should allow the case where from_index == to_index Read more
Source§

unsafe fn set_point_range( &mut self, point_range: Range<usize>, point_data: &[u8], )

Sets the data for the given range of points. This function will generally be more efficient than calling [set_point] multiple times, as [set_point] performs size and index checks on every call, whereas this function can perform them only once. Assumes that the point_data is tightly packed, i.e. stored in an interleaved format with point alignment of 1. Read more
Source§

unsafe fn set_attribute_range( &mut self, attribute: &PointAttributeDefinition, point_range: Range<usize>, attribute_data: &[u8], )

Sets the data for the given attribute for all points in point_range. This function will generally be more efficient than calling [set_attribute] multiple times, as [set_attribute] has to perform type and bounds checks on each call. Read more
Source§

fn as_interleaved_mut(&mut self) -> Option<&mut dyn InterleavedBufferMut<'a>>

Try to get a mutable reference to self as an InterleavedBufferMut. Returns None if self does not implement InterleavedBufferMut
Source§

fn as_columnar_mut(&mut self) -> Option<&mut dyn ColumnarBufferMut<'a>>

Try to get a mutable reference to self as a ColumnarBufferMut. Returns None if self does not implement ColumnarBufferMut
Source§

impl<'a, T: ColumnarBuffer<'a> + BorrowedMutBuffer<'a> + ?Sized> ColumnarBuffer<'a> for BufferSliceMut<'a, T>

Source§

fn get_attribute_ref<'b>( &'b self, attribute: &PointAttributeDefinition, index: usize, ) -> &'b [u8]
where 'a: 'b,

Get an immutable slice to the memory of the given attribute for the point at index. See InterleavedBuffer::get_point_ref for an explanation of the lifetime bounds. Read more
Source§

fn get_attribute_range_ref<'b>( &'b self, attribute: &PointAttributeDefinition, range: Range<usize>, ) -> &'b [u8]
where 'a: 'b,

Get an immutable slice to the memory for the attribute of the given range of points Read more
Source§

fn view_raw_attribute<'b>( &'b self, attribute: &PointAttributeMember, ) -> RawAttributeView<'b>
where 'a: 'b,

Get a raw view over the given attribute from this point buffer. Unlike the typed view that view_attribute returns, this view dereferences to byte slices, but it is potentially more efficient to use than calling get_attribute repeatedly
Source§

impl<'a, T: ColumnarBufferMut<'a> + BorrowedMutBuffer<'a> + ?Sized> ColumnarBufferMut<'a> for BufferSliceMut<'a, T>

Source§

fn get_attribute_mut<'b>( &'b mut self, attribute: &PointAttributeDefinition, index: usize, ) -> &'b mut [u8]
where 'a: 'b,

Get a mutable slice to the memory of the given attribute for the point at index. This is the mutable version of ColumnarBuffer::get_attribute_ref Read more
Source§

fn get_attribute_range_mut<'b>( &'b mut self, attribute: &PointAttributeDefinition, range: Range<usize>, ) -> &'b mut [u8]
where 'a: 'b,

Get a mutable slice to the memory for the attribute of the given range of points. This is the mutable version of ColumnarBuffer::get_attribute_range_ref Read more
Source§

fn view_raw_attribute_mut<'b>( &'b mut self, attribute: &PointAttributeMember, ) -> RawAttributeViewMut<'b>
where 'a: 'b,

Like view_raw_attribute, but returns mutable byte slices of the attribute data
Source§

impl<'a, T: InterleavedBuffer<'a> + BorrowedMutBuffer<'a> + ?Sized> InterleavedBuffer<'a> for BufferSliceMut<'a, T>

Source§

fn get_point_ref<'b>(&'b self, index: usize) -> &'b [u8]
where 'a: 'b,

Get an immutable slice of the point memory of the point at index Read more
Source§

fn get_point_range_ref<'b>(&'b self, range: Range<usize>) -> &'b [u8]
where 'a: 'b,

Get an immutable slice of the memory for the given range of points. This is the range-version of [get_point_ref], see its documentation for more details Read more
Source§

fn view_raw_attribute<'b>( &'b self, attribute: &PointAttributeMember, ) -> RawAttributeView<'b>
where 'a: 'b,

Get a raw view over the given attribute from this point buffer. Unlike the typed view that view_attribute returns, this view dereferences to byte slices, but it is potentially more efficient to use than calling get_attribute repeatedly
Source§

impl<'a, T: InterleavedBufferMut<'a> + BorrowedMutBuffer<'a> + ?Sized> InterleavedBufferMut<'a> for BufferSliceMut<'a, T>

Source§

fn get_point_mut<'b>(&'b mut self, index: usize) -> &'b mut [u8]
where 'a: 'b,

Get a mutable slice of the point memory of the point at index. This is the mutable version of InterleavedBuffer::get_point_ref Read more
Source§

fn get_point_range_mut<'b>(&'b mut self, range: Range<usize>) -> &'b mut [u8]
where 'a: 'b,

Get a mutable slice of the memory for the given range of points. This is the mutable version of InterleavedBuffer::get_point_range_ref Read more
Source§

fn view_raw_attribute_mut<'b>( &'b mut self, attribute: &PointAttributeMember, ) -> RawAttributeViewMut<'b>
where 'a: 'b,

Like view_raw_attribute, but returns mutable byte slices of the attribute data
Source§

impl<'a, T: BorrowedBuffer<'a> + BorrowedMutBuffer<'a> + ?Sized> SliceBuffer<'a> for BufferSliceMut<'a, T>

Source§

type SliceType = BufferSlice<'a, T>

The slice type
Source§

fn slice(&'a self, range: Range<usize>) -> Self::SliceType

Take a immutable slice to this buffer using the given range of points Read more
Source§

impl<'a, T: BorrowedBuffer<'a> + BorrowedMutBuffer<'a> + ?Sized> SliceBufferMut<'a> for BufferSliceMut<'a, T>

Source§

type SliceTypeMut = BufferSliceMut<'a, T>

Source§

fn slice_mut(&'a mut self, range: Range<usize>) -> Self::SliceTypeMut

Take a mutable slice to this buffer using the given range of points Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for BufferSliceMut<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for BufferSliceMut<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for BufferSliceMut<'a, T>
where T: Send + ?Sized,

§

impl<'a, T> Sync for BufferSliceMut<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for BufferSliceMut<'a, T>
where T: ?Sized,

§

impl<'a, T> !UnwindSafe for BufferSliceMut<'a, T>

Blanket Implementations§

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<'a, T> BorrowedBufferExt<'a> for T
where T: BorrowedBuffer<'a>,

Source§

fn view<'b, T: PointType>(&'b self) -> PointView<'a, 'b, Self, T>
where 'a: 'b,

Get a strongly typed view of the point data of this buffer Read more
Source§

fn view_attribute<'b, T: PrimitiveType>( &'b self, attribute: &PointAttributeDefinition, ) -> AttributeView<'a, 'b, Self, T>
where 'a: 'b,

Gets a strongly typed view of the attribute of all points in this buffer Read more
Source§

fn view_attribute_with_conversion<'b, T: PrimitiveType>( &'b self, attribute: &PointAttributeDefinition, ) -> Result<AttributeViewConverting<'a, 'b, Self, T>>
where 'a: 'b,

Like view_attribute, but allows T::data_type() to be different from the data type of
the attribute within this buffer. Read more
Source§

impl<'a, T> BorrowedMutBufferExt<'a> for T
where T: BorrowedMutBuffer<'a>,

Source§

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! Read more
Source§

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! Read more
Source§

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. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.