Skip to main content

serve

Function serve 

Source
pub async fn serve(
    addr: SocketAddr,
    on_event: Option<Arc<dyn Fn(Event) + Send + Sync>>,
    expected_token: Option<String>,
) -> Result<(PatchSender, SocketAddr, JoinHandle<()>)>
Expand description

Bind on addr, spawn the axum server on the current tokio runtime, and return:

  • a PatchSender for the rest of the dev loop to push patches
  • the actual bound address (useful when caller asked for port 0)
  • the spawned server task’s JoinHandle

on_event is an optional observer hook — whisker-cli uses it to render terminal UI on connect/disconnect events.