Crate webrust_macros

Crate webrust_macros 

Source
Expand description

§webrust-macros — Proc-macros for WebRust

Provides the #[gui(...)] attribute and rewrites of print/println to support:

  • F-strings-like formatting: println("Hello {user:?}, score={score:.2}")
  • Inline LaTeX with $( ... ) (preserved for the renderer)
  • #[gui(Font, Size, color, !bg)]: boots the GUI server and applies theme

§#[gui(...)] Attribute

Compact, order-agnostic syntax:

  • Font (capitalized tokens): Arial, Times_New_Roman → spaces restored
  • Size: 14px, 16px, …
  • Text color: black, #222, crimson, …
  • Background: !white, !#f8fafc, …

Example:

use webrust::prelude::*;

#[gui(Times_New_Roman 13px white !fuchsia)]
fn main() {
    let user = "Ada";
    let score = 42.195;
    println("Hi {user:?}, score={score:.2}");
    println("Vector json: { [1,2,3] :j }");
}

§Specifiers inside { ... }

  • {:?} → Debug
  • {:j} → Pretty JSON (HTML-safe, monospace block)
  • {:c} → Compact debug (stringified)
  • {:...} → Any standard format! spec (e.g., :.2, :>6, …)

§Integration

  • #[gui] wraps your function: initializes theme, starts io::gui, runs your code.
  • Calls to print/println are rewritten into optimized format! pipelines.

§Performance

  • Fast scanning with memchr/memmem, minimized allocations
  • Pre-sized buffers and compact tokenization

See webrust::io::gui for the runtime (HTTP API, validation, shutdown).

Attribute Macros§

gui