[][src]Struct luminance::buffer::Buffer

pub struct Buffer<T> { /* fields omitted */ }

A Buffer is a GPU region you can picture as an array.

You’re strongly advised to use either Buffer::from_slice or Buffer::repeat to create a Buffer. The Buffer::new should only be used if you know what you’re doing.

Methods

impl<T> Buffer<T>[src]

pub unsafe fn new<C>(ctx: &mut C, len: usize) -> Buffer<T> where
    C: GraphicsContext
[src]

Create a new Buffer with a given number of elements.

That function leaves the buffer uninitialized, which is unsafe. If you prefer not to use any unsafe function, feel free to use Buffer::from_slice or Buffer::repeat instead.

pub fn from_slice<C, S>(ctx: &mut C, slice: S) -> Buffer<T> where
    C: GraphicsContext,
    S: AsRef<[T]>, 
[src]

Create a buffer out of a slice.

pub fn repeat<C>(ctx: &mut C, len: usize, value: T) -> Self where
    C: GraphicsContext,
    T: Copy
[src]

Create a new Buffer with a given number of elements and ininitialize all the elements to the same value.

pub fn at(&self, i: usize) -> Option<T> where
    T: Copy
[src]

Retrieve an element from the Buffer.

This version checks boundaries.

pub fn whole(&self) -> Vec<T> where
    T: Copy
[src]

Retrieve the whole content of the Buffer.

pub fn set(&mut self, i: usize, x: T) -> Result<(), BufferError> where
    T: Copy
[src]

Set a value at a given index in the Buffer.

This version checks boundaries.

pub fn write_whole(&mut self, values: &[T]) -> Result<(), BufferError>[src]

Write a whole slice into a buffer.

If the slice you pass in has less items than the length of the buffer, you’ll get a BufferError::TooFewValues error. If it has more, you’ll get BufferError::TooManyValues.

This function won’t write anything on any error.

pub fn clear(&mut self, x: T) -> Result<(), BufferError> where
    T: Copy
[src]

Fill the Buffer with a single value.

pub fn fill<V>(&mut self, values: V) -> Result<(), BufferError> where
    V: AsRef<[T]>, 
[src]

Fill the whole buffer with an array.

pub fn to_raw(self) -> RawBuffer[src]

Convert a buffer to its raw representation.

Becareful: once you have called this function, it is not possible to go back to a Buffer.

pub fn as_slice(&mut self) -> Result<BufferSlice<T>, BufferError>[src]

Obtain an immutable slice view into the buffer.

pub fn as_slice_mut(&mut self) -> Result<BufferSliceMut<T>, BufferError>[src]

Obtain a mutable slice view into the buffer.

Methods from Deref<Target = RawBuffer>

pub fn len(&self) -> usize[src]

Get the length of the buffer.

Trait Implementations

impl<T> From<Buffer<T>> for RawBuffer[src]

impl<T> DerefMut for Buffer<T>[src]

impl<T> Deref for Buffer<T>[src]

type Target = RawBuffer

The resulting type after dereferencing.

Auto Trait Implementations

impl<T> !Send for Buffer<T>

impl<T> Unpin for Buffer<T> where
    T: Unpin

impl<T> !Sync for Buffer<T>

impl<T> !RefUnwindSafe for Buffer<T>

impl<T> !UnwindSafe for Buffer<T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]