Trait luminance::buffer::HasBuffer [] [src]

pub trait HasBuffer {
    type ABuffer;
    fn new(size: usize) -> Self::ABuffer;
    fn free(&mut Self::ABuffer);
    fn write_whole<T>(buffer: &Self::ABuffer, values: &[T]) -> Result<()BufferError>;
    fn write<T>(buffer: &Self::ABuffer, offset: usize, x: T) -> Result<()BufferError> where T: Copy;
    fn read_whole<T>(buffer: &Self::ABuffer, nb: usize) -> Vec<T> where T: Copy;
    fn read<T>(buffer: &Self::ABuffer, offset: usize) -> Option<T> where T: Copy;
}

Implement this trait to provide buffers.

Associated Types

type ABuffer

A type representing minimal information to operate on a buffer. For instance, a size, a pointer, a method to retrieve data, a handle, whatever.

Required Methods

fn new(size: usize) -> Self::ABuffer

Create a new buffer with a given size.

fn free(&mut Self::ABuffer)

Destroy a buffer.

fn write_whole<T>(buffer: &Self::ABuffer, values: &[T]) -> Result<()BufferError>

Write values into the buffer.

Warnings

Those warnings are just hints. The behavior for each warning is specific and should be accounted.

Err(BufferError::TooManyValues) if you provide more values than the buffer’s size. In that case, the extra items are just ignored and all others are written; that is, the values argument is considered having the same size as buffer.

Err(BufferError::TooFewValues) if you provide less values than the buffer’s size. In that case, all values are written and the missing ones remain the same in buffer.

fn write<T>(buffer: &Self::ABuffer, offset: usize, x: T) -> Result<()BufferError> where T: Copy

Write a single value in the buffer at a given offset.

Failures

Err(BufferError::Overflow) if you provide an offset that doesn’t lie in the allocated GPU region.

fn read_whole<T>(buffer: &Self::ABuffer, nb: usize) -> Vec<T> where T: Copy

Read all values from the buffer.

fn read<T>(buffer: &Self::ABuffer, offset: usize) -> Option<T> where T: Copy

Read a single value from the buffer at a given offset.

Failures

None if you provide an offset that doesn’t lie in the allocated GPU region.

Implementors