laidout
Laidout is a standalone prepared-document layout kernel. Applications build an
opaque immutable Doc<A> with their own annotation type, prepare it once, and
render with either a column-accurate Fast strategy or an exact cost-minimizing
strategy. A reusable workspace supports ordinary Growable rendering and a
strict Fixed mode with zero allocator calls after reservation. Laidout 0.2
supports Rust 1.85 and newer.
use NonZeroU32;
use ;
let source = group;
let prepared = source.prepare?;
let options = new
.with_strategy;
let mut workspace = growable;
let rendered = render_into?;
assert_eq!;
# Ok::
The borrowed result and its annotation resolvers remain valid only while the
workspace is exclusively borrowed. Use render() for an ergonomic owned
result. For predictable repeated rendering, warm the exact prepared
document/width/strategy, retain workspace.capacity(), then switch to Fixed:
# use NonZeroU32;
# use ;
let prepared = group.prepare?;
let options = new
.with_strategy;
let mut workspace = growable;
drop;
let frozen = workspace.capacity;
workspace.set_mode;
drop; // zero allocator calls
assert_eq!;
# Ok::
Insufficient Fixed storage returns a typed WorkspaceExhausted; it never
changes strategy or publishes an approximate layout. release_capacity()
drops retained high-water storage. A later Growable call can regrow it, while a
later Fixed call reports ordinary capacity exhaustion.
Semantics
- Text is validated and measured once. Engines and tables use the stored Unicode display width; line breaks remain explicit structural document nodes.
- Fast groups use prepared first-stop summaries and never rescan the pending
document.
Fillprobes only its next child. Zero-width text consumes zero columns and no synthetic scan budget exists. - Exact rendering uses stable Pareto frontiers, ordered-choice ties, structural
annotations and penalties, and a checked
(u128 overflow, u64 burden)cost. - Preparation rejects consumer documents whose complete candidate output or
cost domain cannot be represented. The
researchfeature retains unbounded two-BigUintcosts and generic oracle engines. - Laidout has no downstream console dependency or vocabulary. The standalone example and integration test use an application-owned annotation enum.
The proof and verification surfaces are the prepared cost proof,
the 0.2 migration guide, and
examples/standalone.rs.
Laidout is MIT licensed.