WriteStd140

Trait WriteStd140 

Source
pub trait WriteStd140 {
    // Required method
    fn write_std140<W: Write>(&self, writer: &mut Writer<W>) -> Result<usize>;

    // Provided method
    fn std140_size(&self) -> usize { ... }
}
Expand description

Trait implemented for all types that can be written into a buffer as std140 bytes. This type is more general than AsStd140: all AsStd140 types implement WriteStd140, but not the other way around.

While AsStd140 requires implementers to return a type that implements the Std140 trait, WriteStd140 directly writes bytes using a Writer. This makes WriteStd140 usable for writing slices or other DSTs that could not implement AsStd140 without allocating new memory on the heap.

Required Methods§

Source

fn write_std140<W: Write>(&self, writer: &mut Writer<W>) -> Result<usize>

Writes this value into the given Writer using std140 layout rules.

Should return the offset of the first byte of this type, as returned by the first call to Writer::write.

Provided Methods§

Source

fn std140_size(&self) -> usize

The space required to write this value using std140 layout rules. This does not include alignment padding that may be needed before or after this type when written as part of a larger buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> WriteStd140 for [T]
where T: WriteStd140,

Source§

fn write_std140<W: Write>(&self, writer: &mut Writer<W>) -> Result<usize>

Source§

fn std140_size(&self) -> usize

Implementors§

Source§

impl<T> WriteStd140 for T
where T: AsStd140,