[−][src]Struct luminance::buffer::Buffer
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]
C: GraphicsContext,
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]
C: GraphicsContext,
S: AsRef<[T]>,
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]
C: GraphicsContext,
T: Copy,
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]
T: Copy,
Retrieve an element from the Buffer
.
This version checks boundaries.
pub fn whole(&self) -> Vec<T> where
T: Copy,
[src]
T: Copy,
Retrieve the whole content of the Buffer
.
pub fn set(&mut self, i: usize, x: T) -> Result<(), BufferError> where
T: Copy,
[src]
T: Copy,
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]
T: Copy,
Fill the Buffer
with a single value.
pub fn fill<V>(&mut self, values: V) -> Result<(), BufferError> where
V: AsRef<[T]>,
[src]
V: AsRef<[T]>,
Fill the whole buffer with an array.
pub fn into_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.
pub fn is_empty(&self) -> bool
[src]
Check whether the buffer is empty.
Trait Implementations
impl<T> From<Buffer<T>> for RawBuffer
[src]
impl<T> Deref for Buffer<T>
[src]
type Target = RawBuffer
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<T> DerefMut for Buffer<T>
[src]
Auto Trait Implementations
impl<T> !Send for Buffer<T>
impl<T> Unpin for Buffer<T> where
T: Unpin,
T: Unpin,
impl<T> !Sync for Buffer<T>
impl<T> !UnwindSafe for Buffer<T>
impl<T> !RefUnwindSafe for Buffer<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,