pub trait BorrowedBufferExt<'a>: BorrowedBuffer<'a> {
// Provided methods
fn view<'b, T: PointType>(&'b self) -> PointView<'a, 'b, Self, T>
where 'a: 'b { ... }
fn view_attribute<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition,
) -> AttributeView<'a, 'b, Self, T>
where 'a: 'b { ... }
fn view_attribute_with_conversion<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition,
) -> Result<AttributeViewConverting<'a, 'b, Self, T>>
where 'a: 'b { ... }
}Expand description
Extension trait for BorrowedBuffer that allows obtaining strongly-typed views over points and
attributes.
§Notes
The view... methods on this type are implemented in an extension trait and not the base trait
BorrowedBuffer so that we retain the option to create trait objects for types implementing
BorrowedBuffer, while also allowing both static types T: BorrowedBuffer and dynamic trait object
types (dyn BorrowedBuffer) to be used for views. I.e. this makes the following code possible:
let layout = ...;
let buffer = VectorBuffer::new_from_layout(layout);
let view_from_sized_type = buffer.view::<Vector3<f64>>(&POSITION_3D);
// In previous pasture version, this code was not possible because views required sized types:
let buffer_trait_object: &dyn InterleavedBuffer = buffer.as_interleaved().unwrap();
let view_from_trait_object = buffer_trait_object.view::<Vector3<f64>>(&POSITION_3D);Provided Methods§
Sourcefn view<'b, T: PointType>(&'b self) -> PointView<'a, 'b, Self, T>where
'a: 'b,
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
§Panics
Panics if T::layout() does not match the PointLayout of this buffer
Sourcefn view_attribute<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition,
) -> AttributeView<'a, 'b, Self, T>where
'a: 'b,
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
§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
Sourcefn view_attribute_with_conversion<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition,
) -> Result<AttributeViewConverting<'a, 'b, Self, T>>where
'a: 'b,
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.
§Panics
If T::data_type() does not match the data type of attribute
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.