Expand description
Generic rebuild-worker driver for dev servers.
Spawns a background OS thread that owns the rebuild loop:
- Block waiting for a tick.
- Drain any extra ticks queued before the thread woke up — they coalesce into a single rebuild.
- Run the user-supplied rebuild closure.
- Drain any ticks that arrived during the rebuild — if any did, re-tick ourselves so the next iteration runs without waiting.
- Report success / error via
RebuildReporterand broadcast the corresponding live-reload event.
The closure is the only thing that varies between consumers
(webui-cli builds and renders an app, webui-press rebuilds a docs
site). It returns Result<Vec<String>, RebuildError>: the Ok value is a
list of plain advisory lines to print under the rebuild line, and the Err
lets the worker print a terminal rendering and broadcast a plain one to
browsers.
Structs§
- Rebuild
Error - Failure returned by a rebuild closure.
- Rebuild
Worker - Owns a rebuild thread. Keep this handle alive for the server’s lifetime.
Functions§
- spawn_
rebuild_ worker - Spawn the rebuild worker on a dedicated OS thread and return the
owned handle used to shut it down. The watcher closure should
call
tx.try_send(paths)with the changed paths for every filesystem event burst — failed sends (channel full) are intentional coalescing. ObtaintxviaRebuildWorker::sender.
Type Aliases§
- Tick
Sender - Tick sender given to the watcher closure. Cheap to clone.