logo

Trait bevy::render::render_resource::std140::Std140[]

pub unsafe trait Std140: Copy + Zeroable + Pod {
    type Padded: Std140Convertible<Self>;

    const ALIGNMENT: usize;
    const PAD_AT_END: bool;
    fn as_bytes(&self) -> &[u8]
Notable traits for &'_ [u8]
impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
{ ... } }
Expand description

Trait implemented for all std140 primitives. Generally should not be implemented outside this crate.

Associated Types

Padded type (Std140Padded specialization) The usual implementation is type Padded = Std140Padded<Self, {align_offset(size_of::(), max(16, ALIGNMENT))}>;

Associated Constants

The required alignment of the type. Must be a power of two.

This is distinct from the value returned by std::mem::align_of because AsStd140 structs do not use Rust’s alignment. This enables them to control and zero their padding bytes, making converting them to and from slices safe.

Whether this type requires a padding at the end (ie, is a struct or an array of primitives). See https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 (rule 4 and 9)

Provided methods

Casts the type to a byte array. Implementors should not override this method.

Safety

This is always safe due to the requirements of [bytemuck::Pod] being a prerequisite for this trait.

Implementations on Foreign Types

Implementors