Trait BufferVec

Source
pub trait BufferVec<T: BufferVecItem>:
    Debug
    + Clone
    + From<Buffer>
    + Index<usize>
    + IndexMut<usize>
    + Index<Range<usize>>
    + IndexMut<Range<usize>>
    + Index<RangeTo<usize>>
    + IndexMut<RangeTo<usize>>
    + Index<RangeFull>
    + IndexMut<RangeFull>
    + Index<RangeInclusive<usize>>
    + IndexMut<RangeInclusive<usize>>
    + Index<RangeToInclusive<usize>>
    + IndexMut<RangeToInclusive<usize>> {
Show 16 methods // Required methods fn get_buffer(&self) -> &Buffer; fn get_buffer_mut(&mut self) -> &mut Buffer; fn get_target(&self) -> BufferTarget; fn set_target(&mut self, target: BufferTarget); fn len(&self) -> usize; fn capacity(&self) -> usize; fn resize(&mut self, new_len: usize, value: T) -> Result<(), GLCoreError>; fn shrink_to_fit(&mut self) -> Result<(), GLCoreError>; fn get(&self, index: usize) -> Result<T, GLCoreError>; fn set(&mut self, index: usize, data: &T) -> Result<(), GLCoreError>; fn get_slice_of_data( &self, start_index: usize, len: usize, ) -> Result<Vec<T>, GLCoreError>; fn set_slice_of_data( &mut self, start_index: usize, data: &[T], ) -> Result<(), GLCoreError>; // Provided methods fn flush(&mut self) -> Result<(), GLCoreError> { ... } fn is_empty(&self) -> bool { ... } fn bind<'a>(&'a self) -> Result<BufferBind<'a>, GLCoreError> { ... } fn bind_to<'a>( &'a self, target: BufferTarget, ) -> Result<BufferBind<'a>, GLCoreError> { ... }
}
Expand description

The BufferVec trait

Required Methods§

Source

fn get_buffer(&self) -> &Buffer

Get the underlying Buffer

Source

fn get_buffer_mut(&mut self) -> &mut Buffer

Get the underlying Buffer as mut

Source

fn get_target(&self) -> BufferTarget

Get the default binding target of the buffer

Source

fn set_target(&mut self, target: BufferTarget)

Set the binding target of the buffer

Source

fn len(&self) -> usize

Get the size of the buffer

Source

fn capacity(&self) -> usize

Get the capacity of the buffer

Source

fn resize(&mut self, new_len: usize, value: T) -> Result<(), GLCoreError>

Resizes to the new size, reallocate the buffer if the new size is larger

Source

fn shrink_to_fit(&mut self) -> Result<(), GLCoreError>

Shrink to the exact number of items

Source

fn get(&self, index: usize) -> Result<T, GLCoreError>

Retrieve a single item from the buffer in the GPU

Source

fn set(&mut self, index: usize, data: &T) -> Result<(), GLCoreError>

Update a single item from the buffer in the GPU

Source

fn get_slice_of_data( &self, start_index: usize, len: usize, ) -> Result<Vec<T>, GLCoreError>

Retrieve a slice of items from the buffer in the GPU

Source

fn set_slice_of_data( &mut self, start_index: usize, data: &[T], ) -> Result<(), GLCoreError>

Update a slice of itrems to the buffer in the GPU

Provided Methods§

Source

fn flush(&mut self) -> Result<(), GLCoreError>

Flush the buffer to the GPU if it has a cache in the system memory

Source

fn is_empty(&self) -> bool

Check if the content of the buffer is empty

Source

fn bind<'a>(&'a self) -> Result<BufferBind<'a>, GLCoreError>

Create a BufferBind to use the RAII system to manage the binding state.

Source

fn bind_to<'a>( &'a self, target: BufferTarget, ) -> Result<BufferBind<'a>, GLCoreError>

Bind to a specific target. WILL NOT change the default target of the buffer. Create a BufferBind to use the RAII system to manage the binding state, while change the binding target.

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.

Implementors§