Skip to main content

Module client

Module client 

Source
Expand description

Client side: connect to the project’s daemon, spawning it on first use.

Functions§

request
Send one request and collect the whole response into a Vec (for small responses).
request_existing
Like request but never spawns — returns None if no daemon is listening. For stop/status.
request_stream
Send one request to the daemon for root (spawning it if needed), streaming the response to sink. Returns the total number of bytes written.
spawn_daemon
Spawn a detached background daemon (rgx --server) rooted at root.
store_cursor
Park a pagination cursor blob in root’s daemon (spawning it if needed); returns the short token to print in place of the blob.
take_cursor
Redeem a pagination token at root’s daemon. Ok(None) means it expired or was already used — the daemon replies with an empty frame, or there’s no daemon at all (so no stored cursors). Uses a connect-only request: a stale token must never spawn a fresh daemon (and a cold index build) just to discover it’s gone.
wait_until_stopped
Poll until no daemon is listening for root, up to ~5s. Used by restart after a Shutdown so the fresh daemon isn’t spawned while the old one still holds the endpoint (it would exit as a no-op). Returns true once the endpoint is free, false on timeout.
watch
Subscribe to the daemon’s live status (spawning it if needed), invoking render with each status frame as it arrives, until the daemon closes the stream (or the process is interrupted).