Brick

Trait Brick 

Source
pub trait Brick: Send + Sync {
    // Required methods
    fn brick_name(&self) -> &'static str;
    fn assertions(&self) -> &[BrickAssertion];
    fn budget(&self) -> BrickBudget;
    fn verify(&self) -> BrickVerification;
    fn to_html(&self) -> String;
    fn to_css(&self) -> String;

    // Provided methods
    fn test_id(&self) -> Option<&str> { ... }
    fn can_render(&self) -> bool { ... }
}
Expand description

Core Brick trait - the foundation of the Brick Architecture.

All UI components implement this trait. The trait defines:

  1. Assertions that must pass for the brick to be valid
  2. Performance budget that must not be exceeded
  3. HTML/CSS generation for rendering targets

§Trait Bound

Presentar’s Widget trait requires Brick:

pub trait Widget: Brick + Send + Sync { ... }

This ensures every widget has verifiable assertions and budgets.

Required Methods§

Source

fn brick_name(&self) -> &'static str

Get the brick’s unique type name

Source

fn assertions(&self) -> &[BrickAssertion]

Get all assertions for this brick

Source

fn budget(&self) -> BrickBudget

Get the performance budget

Source

fn verify(&self) -> BrickVerification

Verify all assertions against current state

Returns a verification result with passed/failed assertions.

Source

fn to_html(&self) -> String

Generate HTML for this brick (WASM target)

Returns the HTML string that represents this brick. Must be deterministic (same state → same output).

Source

fn to_css(&self) -> String

Generate CSS for this brick (WASM target)

Returns the CSS rules for styling this brick. Must be deterministic and scoped to avoid conflicts.

Provided Methods§

Source

fn test_id(&self) -> Option<&str>

Get the test ID for DOM queries

Source

fn can_render(&self) -> bool

Check if this brick can be rendered (all assertions pass)

Implementors§