pub trait BorrowedBuffer<'a> {
Show 13 methods // Required methods fn len(&self) -> usize; fn point_layout(&self) -> &PointLayout; fn get_point(&self, index: usize, data: &mut [u8]); fn get_point_range(&self, range: Range<usize>, data: &mut [u8]); unsafe fn get_attribute_unchecked( &self, attribute_member: &PointAttributeMember, index: usize, data: &mut [u8] ); // Provided methods fn is_empty(&self) -> bool { ... } fn get_attribute( &self, attribute: &PointAttributeDefinition, index: usize, data: &mut [u8] ) { ... } fn get_attribute_range( &self, attribute: &PointAttributeDefinition, point_range: Range<usize>, data: &mut [u8] ) { ... } fn view<'b, T: PointType>(&'b self) -> PointView<'a, 'b, Self, T> where Self: Sized, 'a: 'b { ... } fn view_attribute<'b, T: PrimitiveType>( &'b self, attribute: &PointAttributeDefinition ) -> AttributeView<'a, 'b, Self, T> where Self: Sized, 'a: 'b { ... } fn view_attribute_with_conversion<'b, T: PrimitiveType>( &'b self, attribute: &PointAttributeDefinition ) -> Result<AttributeViewConverting<'a, 'b, Self, T>> where Self: Sized, 'a: 'b { ... } fn as_interleaved(&self) -> Option<&dyn InterleavedBuffer<'a>> { ... } fn as_columnar(&self) -> Option<&dyn ColumnarBuffer<'a>> { ... }
}
Expand description

Base trait for all point buffers in pasture. The only assumption this trait makes is that the underlying memory can be borrowed by the buffer. Provides point and attribute accessors by untyped value (i.e. copying into a provided &mut [u8])

Required Methods§

source

fn len(&self) -> usize

Returns the length of this buffer, i.e. the number of points

Example
use pasture_core::containers::*;
use pasture_core::layout::*;

let buffer = VectorBuffer::new_from_layout(PointLayout::default());
assert_eq!(0, buffer.len());
source

fn point_layout(&self) -> &PointLayout

Returns the PointLayout of this buffer. The PointLayout describes the structure of a single point at runtime.

Example
use pasture_core::containers::*;
use pasture_core::layout::*;

let layout = PointLayout::from_attributes(&[attributes::POSITION_3D, attributes::INTENSITY]);
let buffer = VectorBuffer::new_from_layout(layout.clone());
assert_eq!(layout, *buffer.point_layout());
source

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

Writes the data for the point at index from this buffer into data

Panics

May panic if index is out of bounds. May panic if data.len() does not equal self.point_layout().size_of_point_entry()

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

Panics

May panic if range is out of bounds. May panic if data.len() does not equal range.len() * self.point_layout().size_of_point_entry()

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

Safety

Requires attribute_member to be a part of this buffer’s PointLayout

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if this buffer does not store any points

Example
use pasture_core::containers::*;
use pasture_core::layout::*;

let buffer = VectorBuffer::new_from_layout(PointLayout::default());
assert!(buffer.is_empty());
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

Panics

May panic if attribute is not part of the PointLayout of this buffer. It is implementation-defined whether data type conversions are supported (i.e. the buffer stores positions as Vector3<f64>, but get_attribute is called with Vector3<f32> as the attribute data type), but generally assume that conversions are not possible! May panic if data.len() does not equal the size of a single value of the data type of attribute

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.

Panics

May panic if attribute is not part of the PointLayout of this buffer. May panic if point_range is out of bounds. May panic if data.len() does not equal attribute.size() * point_range.len()

source

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

Get a strongly typed view of the point data of this buffer

Panics

Panics if T::layout() does not match the PointLayout of this buffer

source

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

Gets a strongly typed view of the attribute of all points in this buffer

Panics

If attribute is not part of the PointLayout of this buffer. If T::data_type() does not match the data type of the attribute within the buffer

source

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

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

Panics

If T::data_type() does not match the data type of attribute

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

Implementors§