How p-kraszewski/pakr-assert-size works
Macro Processing Pipeline
• Integration with Rust's compilation process
Main Components
a. Input Layer
• Rust struct definitions
• Attribute macros (#[assert_size] and #[assert_size_fits])
b. Processing Layer
• Size calculation component
• Assertion validation component
c. Output Layer
• Compile-time error generation
• Successful compilation path
Input Section (Top)
• It to two parallel branches showing the two main attributes:
• #[assert_size(n)]
• #[assert_size_fits(n)]
Processing Section (Middle)
• Struct layout analysis
• Memory size calculation
• A "Validation Logic" component with two paths:
• Exact size matching (for assert_size)
• Maximum size checking (for assert_size_fits)
Output Section (Bottom)
• Split into two possible outcomes:
• Compilation Success (Green)
• Compilation Error (Red)
Styling Guidelines:
• Use blue for input components
• Green for successful paths
• Red for error paths
• Gray for processing components
Labels
• Byte sizes in the examples
• Notes about #[repr(C, packed)] requirements
• Example struct layouts
Important Details to Capture:
Compile-Time Nature
• That all operations happen during compilation
• Integration with Rust's macro system
Type Safety
• That size assertions are statically verified
• Relationship with Rust's type system
Error Handling
• How compilation errors are generated
• Example error messages
Level of Detail:
• Keep the main flow simple and clear
• Notes about size calculation rules
Remember to include a small example section showing the transformation from source code to either successful compilation or error generation, similar to the examples in the README.