[][src]Struct web_glitz::buffer::BufferView

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

A view on a segment or the whole of a Buffer.

Methods

impl<'a, T> BufferView<'a, T> where
    T: ?Sized
[src]

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.

impl<'a, T> BufferView<'a, T> where
    T: Copy
[src]

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.

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

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::UsageHint;

let buffer = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
let view = buffer.view();

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::UsageHint;

let buffer = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
let view = buffer.view();

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

Unsafe

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

impl<'a, T> BufferView<'a, [T]> where
    T: Copy
[src]

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> VertexBuffer for BufferView<'a, [T]> where
    T: Vertex
[src]

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

type Vertex = T

impl<'a, F> IndexBuffer for BufferView<'a, [F]> where
    F: IndexFormat
[src]

impl<'a, T> BufferResource for BufferView<'a, T> where
    T: InterfaceBlock
[src]

type Binding = BufferBinding<'a, T>

The type of binding for this resource.

impl<'a, T> Into<BufferView<'a, T>> for &'a Buffer<T> where
    T: ?Sized
[src]

impl<'a, T> Clone for BufferView<'a, T>[src]

impl<'a, T> Clone for BufferView<'a, [T]>[src]

impl<'a, T> Copy for BufferView<'a, T>[src]

impl<'a, T> Copy for BufferView<'a, [T]>[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]