Skip to main content

SoaLayout

Trait SoaLayout 

Source
pub trait SoaLayout: Component {
    const FIELD_COUNT: usize;
    const FIELD_NAMES: &'static [&'static str];

    // Required methods
    fn scatter_push(&self, fields: &mut [Vec<f32>]);
    fn scatter_set(&self, fields: &mut [Vec<f32>], row: usize);
    fn gather(fields: &[Vec<f32>], row: usize) -> Self;
}
Expand description

Per-type knowledge the generic FieldSoaColumn needs to scatter a component into its f32 field arrays and gather it back.

Generated by #[derive(Component)] + #[component(layout = "soa")] for structs whose fields are all f32. The array order matches field declaration order.

Required Associated Constants§

Source

const FIELD_COUNT: usize

Number of f32 fields this component decomposes into.

Source

const FIELD_NAMES: &'static [&'static str]

Field names in declaration order (for the glass-box / debugging).

Required Methods§

Source

fn scatter_push(&self, fields: &mut [Vec<f32>])

Appends each of self’s fields onto the matching field array (one new row).

fields.len() == FIELD_COUNT is guaranteed by the caller.

Source

fn scatter_set(&self, fields: &mut [Vec<f32>], row: usize)

Overwrites row row of every field array with self’s fields.

fields.len() == FIELD_COUNT and row in bounds are guaranteed.

Source

fn gather(fields: &[Vec<f32>], row: usize) -> Self

Reconstructs a value from row row across the field arrays.

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.

Implementors§