glium::buffer

Trait Content

source
pub unsafe trait Content {
    type Owned;

    // Required methods
    unsafe fn read<F, E>(size: usize, _: F) -> Result<Self::Owned, E>
       where F: FnOnce(&mut Self) -> Result<(), E>;
    fn get_elements_size() -> usize;
    fn to_void_ptr(&self) -> *const ();
    fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut Self>;
    fn is_size_suitable(_: usize) -> bool;
}
Expand description

Trait for types of data that can be put inside buffers.

Required Associated Types§

source

type Owned

A type that holds a sized version of the content.

Required Methods§

source

unsafe fn read<F, E>(size: usize, _: F) -> Result<Self::Owned, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Prepares an output buffer, then turns this buffer into an Owned. User-provided closure F must only write to and not read from &mut Self.

source

fn get_elements_size() -> usize

Returns the size of each element.

source

fn to_void_ptr(&self) -> *const ()

Produces a pointer to the data.

source

fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut Self>

Builds a pointer to this type from a raw pointer.

source

fn is_size_suitable(_: usize) -> bool

Returns true if the size is suitable to store a type like this.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Content for [T]
where T: Copy,

source§

type Owned = Vec<T>

source§

unsafe fn read<F, E>(size: usize, f: F) -> Result<Vec<T>, E>
where F: FnOnce(&mut [T]) -> Result<(), E>,

source§

fn get_elements_size() -> usize

source§

fn to_void_ptr(&self) -> *const ()

source§

fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut [T]>

source§

fn is_size_suitable(size: usize) -> bool

Implementors§

source§

impl<T> Content for T
where T: Copy,

source§

type Owned = T