Skip to main content

shape_layout

Attribute Macro shape_layout 

Source
#[shape_layout]
Expand description

Emits the layouts a block of shape declarations states, beside the declarations themselves.

Written outside #[ext(… defunc(via = shape))], which it re-emits untouched:

#[shape_layout]
#[ext(name = UserShapeExt, defunc(via = shape))]
pub impl<This> This
where
    This: ShapeAlg + FieldAlg,
{
    fn user_shape(&self) {
        self.record().field::<String>(display_name, self.text())
    }
}

Each member states the type carrying it, which is what a layout is emitted from. An optional argument states how the layout writes its names, defaulting to "camelCase".

The emitted layout derives serde::Serialize and serde::Deserialize, so a crate using this needs serde among its dependencies.