Trait pasture_core::containers::OwningBuffer
source · pub trait OwningBuffer<'a>: BorrowedMutBuffer<'a> + Sized {
// Required methods
unsafe fn push_points(&mut self, point_bytes: &[u8]);
fn append_interleaved<'b, B: InterleavedBuffer<'b>>(&mut self, other: &B);
fn append_columnar<'b, B: ColumnarBuffer<'b>>(&mut self, other: &B);
fn resize(&mut self, count: usize);
fn clear(&mut self);
// Provided method
fn append<'b, B: BorrowedBuffer<'b>>(&mut self, other: &B) { ... }
}
Expand description
Trait for point buffers that own their memory. Compared to [BorrowedBufferMut
], buffers that implement
this trait support the following additional capabilities:
- Pushing point data into the buffer using
push_points
- Appending other buffers to the end of this buffer using
append
,append_interleaved
, andappend_columnar
- Resizing and clearing the contents of the buffer using
resize
andclear
Required Methods§
sourceunsafe fn push_points(&mut self, point_bytes: &[u8])
unsafe fn push_points(&mut self, point_bytes: &[u8])
Push the raw memory for a range of points into this buffer. Works similar to Vec::push
Safety
point_bytes
must contain the raw memory for a whole number of points in the PointLayout
of this buffer.
This property is not checked at runtime, so this function is very unsafe!
Panics
May panic if point_bytes.len()
is not a multiple of self.point_layout().size_of_point_record()
sourcefn append_interleaved<'b, B: InterleavedBuffer<'b>>(&mut self, other: &B)
fn append_interleaved<'b, B: InterleavedBuffer<'b>>(&mut self, other: &B)
Appends data from the given interleaved buffer to the end of this buffer
Note
Why is there no single append
function? As far as I understand the currently Rust rules, we can’t
state that two traits are mutually exclusive. So in principle there could be some point buffer type
that implements both InterleavedBuffer
and ColumnarBuffer
. So we can’t auto-detect from the type
B
whether we should use an implementation that assumes interleaved memory layout, or one that assumes
columnar memory layout. We could always be conservative and assume neither layout and use the get_point
and set_point
API, but this is pessimistic and has suboptimal performance. So instead, we provide
two independent functions that allow more optimal implementations if the memory layouts of Self
and
B
match.
Panics
If self.point_layout()
does not equal other.point_layout()
sourcefn append_columnar<'b, B: ColumnarBuffer<'b>>(&mut self, other: &B)
fn append_columnar<'b, B: ColumnarBuffer<'b>>(&mut self, other: &B)
Appends data from the given columnar buffer to the end of this buffer
Panics
If self.point_layout()
does not equal other.point_layout()
Provided Methods§
sourcefn append<'b, B: BorrowedBuffer<'b>>(&mut self, other: &B)
fn append<'b, B: BorrowedBuffer<'b>>(&mut self, other: &B)
Appends data from the given buffer to the end of this buffer. Makes no assumptions about the memory
layout of other
. If you know the memory layout of other
, consider using append_interleaved
or
append_columnar
instead, as these will give better performance.
Panics
If self.point_layout()
does not equal other.point_layout()