[][src]Struct web_glitz::buffer::BufferViewMut

pub struct BufferViewMut<'a, T> where
    T: ?Sized
{ /* fields omitted */ }

Implementations

impl<'a, T> BufferViewMut<'a, [T]>[src]

pub fn get_mut<I>(&mut self, index: I) -> Option<BufferViewMut<'_, I::Output>> where
    I: BufferViewMutSliceIndex<T>, 
[src]

Returns a BufferViewMut on an element or a sub-slice of the elements this BufferViewMut, depending on the type of index.

  • If given a position, returns a view on the element at that position or None if out of bounds.
  • If given a range, returns a view on the sub-slice of elements corresponding to that range, or None if out of bounds.

Examples

use web_glitz::buffer::{Buffer, BufferViewMut, UsageHint};

let mut buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
let mut view = BufferViewMut::from(&mut buffer);

view.get_mut(1); // Some BufferViewMut<f32> containing `2.0`
view.get_mut(1..3); // Some BufferViewMut<[f32]> containing `[2.0, 3.0]`
view.get_mut(..2); // Some BufferViewMut<[f32]> containing `[1.0 2.0]`
view.get_mut(4); // None (index out of bounds)

pub unsafe fn get_unchecked_mut<I>(
    &mut self,
    index: I
) -> BufferViewMut<'_, I::Output> where
    I: BufferViewMutSliceIndex<T>, 
[src]

Returns a BufferViewMut on an element or a sub-slice of the elements this BufferViewMut, depending on the type of index, without doing bounds checking.

  • If given a position, returns a view on the element at that position, without doing bounds checking.
  • If given a range, returns a view on the slice of elements corresponding to that range, without doing bounds checking.

Examples

use web_glitz::buffer::{Buffer, BufferViewMut, UsageHint};

let mut buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
let mut view = BufferViewMut::from(&mut buffer);

unsafe { view.get_unchecked_mut(1) }; // BufferViewMut<f32> containing `2.0`

Unsafe

Only safe if index is in bounds. See [get_mut] for a safe alternative.

Methods from Deref<Target = BufferView<'a, T>>

pub fn usage_hint(&self) -> UsageHint[src]

Returns the UsageHint that was specified for the Buffer view by this BufferView when it was created.

See UsageHint for details.

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

The size in bytes of the viewed buffer region.

pub fn upload_command<D>(&self, data: D) -> UploadCommand<T, D> where
    D: Borrow<T> + Send + Sync + 'static, 
[src]

Returns a command which, when executed will replace the data viewed by this BufferView with the given data.

This will modify the viewed Buffer, the buffer (and any other views on the same data) will be affected by this change.

pub fn download_command(&self) -> DownloadCommand<T>[src]

Returns a command which, when executed will copy the data viewed by in this BufferView into a Box.

When the task is finished, the Box containing the copied data will be output.

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

Returns the number of elements contained in this Buffer.

pub fn get<I>(&self, index: I) -> Option<BufferView<'_, I::Output>> where
    I: BufferViewSliceIndex<T>, 
[src]

Returns a BufferView on an element or a sub-slice of the elements this Buffer, depending on the type of index.

  • If given a position, returns a view on the element at that position or None if out of bounds.
  • If given a range, returns a view on the sub-slice of elements corresponding to that range, or None if out of bounds.

Examples

use web_glitz::buffer::{Buffer, BufferView, UsageHint};

let buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
let view = BufferView::from(&buffer);

view.get(1); // Some BufferView<f32> containing `2.0`
view.get(1..3); // Some BufferView<[f32]> containing `[2.0, 3.0]`
view.get(..2); // Some BufferView<[f32]> containing `[1.0 2.0]`
view.get(4); // None (index out of bounds)

pub unsafe fn get_unchecked<I>(&self, index: I) -> BufferView<'_, I::Output> where
    I: BufferViewSliceIndex<T>, 
[src]

Returns a BufferView on an element or a sub-slice of the elements this BufferView, depending on the type of index, without doing bounds checking.

  • If given a position, returns a view on the element at that position, without doing bounds checking.
  • If given a range, returns a view on the slice of elements corresponding to that range, without doing bounds checking.

Examples

use web_glitz::buffer::{Buffer, BufferView, UsageHint};

let buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
let view = BufferView::from(&buffer);

unsafe { view.get_unchecked(1) }; // BufferView<f32> containing `2.0`

Unsafe

Only safe if index is in bounds. See [get] for a safe alternative.

pub fn upload_command<D>(&self, data: D) -> UploadCommand<[T], D> where
    D: Borrow<[T]> + Send + Sync + 'static, 
[src]

Returns a command which, when executed will replace the elements viewed by this BufferView with the elements in given data.

If the data contains fewer elements than the slice viewed by this BufferView, then only the first N elements will be replaced, where N is the number of elements in the given data.

If the data contains more elements than the slice viewed by this Buffer, then only the first M elements in the data will be used to update this Buffer, where M is the number of elements in the slice viewed by the BufferView.

This will modify the viewed Buffer, the buffer (and any other views on the same data) will be affected by this change.

pub fn download_command(&self) -> DownloadCommand<[T]>[src]

Returns a command which, when executed will copy the elements viewed by in this BufferView into a Box.

When the task is finished, the Box containing the copied elements will be output.

Trait Implementations

impl<'a, T> Deref for BufferViewMut<'a, T> where
    T: ?Sized
[src]

type Target = BufferView<'a, T>

The resulting type after dereferencing.

impl<'a, T, const LEN: usize> From<&'a mut Buffer<[T; LEN]>> for BufferViewMut<'a, [T]>[src]

impl<'a, T> From<&'a mut Buffer<T>> for BufferViewMut<'a, T> where
    T: ?Sized
[src]

impl<'a, T> TransformFeedbackBuffer for BufferViewMut<'a, [T]>[src]

impl<'a, T> TypedTransformFeedbackBuffer for BufferViewMut<'a, [T]> where
    T: TransformFeedback
[src]

impl<'a, T> TypedVertexBuffer for BufferViewMut<'a, [T]> where
    T: Vertex
[src]

type Vertex = T

impl<'a, 'b, T> TypedVertexBuffer for &'a BufferViewMut<'b, [T]> where
    T: Vertex
[src]

type Vertex = T

impl<'a, 'b, T> TypedVertexBuffer for &'a mut BufferViewMut<'b, [T]> where
    T: Vertex
[src]

type Vertex = T

impl<'a, T> VertexBuffer for BufferViewMut<'a, [T]>[src]

impl<'a, 'b, T> VertexBuffer for &'a BufferViewMut<'b, [T]>[src]

impl<'a, 'b, T> VertexBuffer for &'a mut BufferViewMut<'b, [T]>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for BufferViewMut<'a, T>

impl<'a, T> !Send for BufferViewMut<'a, T>

impl<'a, T> !Sync for BufferViewMut<'a, T>

impl<'a, T: ?Sized> Unpin for BufferViewMut<'a, T>

impl<'a, T> !UnwindSafe for BufferViewMut<'a, T>

Blanket Implementations

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

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

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

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

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

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[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.