Struct Buffer

Source
pub struct Buffer { /* private fields */ }
Expand description

A handle to a VBO buffer in linear memory, to be used with Info. This handle is reference counted so can be cheaply cloned and used with mutliple Info instances without duplicating memory.

Implementations§

Source§

impl Buffer

Source

pub fn new<T: Sized + Copy + 'static>(data: &[T]) -> Buffer

Allocate a new Buffer in Linear memory and copy data into it. Each element of data should correspond to data for a single vertex.

If you already have an owned [Vec] in Linear memory then Buffer::new_in_linear should be preferred to take ownership of that allocation instead of reallocating and copying.

Source

pub fn new_with_stride(data: &[u8], stride: usize) -> Option<Buffer>

Allocate a new Buffer in Linear memory and copy data into it. The stride should correspond to the number of bytes in data per single vertex.

If you already have an owned [Vec] in Linear memory then Buffer::new_in_linear_with_stride should be preferred to take ownership of that allocation instead of reallocating and copying.

§Errors
  • If the length of data is not a mutliple of stride
Source

pub fn new_in_linear<B: BufferData>(data: B) -> Buffer

Convert an existing buffer allocated in Linear memory to a Buffer to be used with Info. Each element in data should correspond with data for a single vertex.

Source

pub fn new_in_linear_with_stride( data: impl BufferData, stride: usize, ) -> Option<Buffer>

Convert an existing buffer of unstructured data allocated in Linear memory e.g. Vec<u8, LinearAllocator> to a Buffer to be used with Info. Each element in data should correspond with data for a single vertex.

§Errors
  • If the length of data is not a mutliple of stride
Source

pub fn as_ptr(&self) -> *const c_void

Source

pub fn stride(&self) -> isize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Clone for Buffer

Source§

fn clone(&self) -> Buffer

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Buffer

§

impl !RefUnwindSafe for Buffer

§

impl !Send for Buffer

§

impl !Sync for Buffer

§

impl Unpin for Buffer

§

impl !UnwindSafe for Buffer

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where 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>

Performs the conversion.