Skip to main content

Module packing

Module packing 

Source
Expand description

Shared code generation utilities for storage slot packing.

This module provides common logic for computing slot and offset assignments used by both the #[derive(Storable)] and #[contract] macros.

Structsยง

LayoutField ๐Ÿ”’
A single field in the storage layout with computed slot information.
PackingConstants ๐Ÿ”’
Helper for generating packing constant identifiers

Enumsยง

SlotAssignment ๐Ÿ”’
Represents how a slot is assigned

Functionsยง

allocate_slots ๐Ÿ”’
Build layout IR from field information.
classify_field_type ๐Ÿ”’
Classify a field based on its type.
const_name ๐Ÿ”’
Convert a field name to a constant name (SCREAMING_SNAKE_CASE)
gen_collision_check_fn ๐Ÿ”’
Generate collision detection debug assertions for a field against all other fields.
gen_constants_from_ir ๐Ÿ”’
Generate packing constants from layout IR.
gen_layout_ctx_expr ๐Ÿ”’
Generate a LayoutCtx expression for accessing a field.
gen_slot_packing_logic ๐Ÿ”’
Generate slot packing decision logic.
get_neighbor_slot_refs ๐Ÿ”’
Helper to compute prev and next slot constant references for a field at a given index.