Skip to main content

Module worker

Module worker 

Source
Expand description

Generic rebuild-worker driver for dev servers.

Spawns a background OS thread that owns the rebuild loop:

  1. Block waiting for a tick.
  2. Drain any extra ticks queued before the thread woke up — they coalesce into a single rebuild.
  3. Run the user-supplied rebuild closure.
  4. Drain any ticks that arrived during the rebuild — if any did, re-tick ourselves so the next iteration runs without waiting.
  5. Report success / error via RebuildReporter and 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§

RebuildError
Failure returned by a rebuild closure.

Functions§

spawn_rebuild_worker
Spawn the rebuild worker on a dedicated OS thread and return the sender used to enqueue rebuild ticks. 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.

Type Aliases§

TickSender
Tick sender given to the watcher closure. Cheap to clone.