Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

The embedder’s answer to a request about the process, not the document. The embedder’s answer to a request about the process, not the document.

crate::in_process::DocumentControl refuses Relaunch and Quit, and that refusal is correct: a document cannot restart the program it is being displayed by. Somebody above the document has to answer, and which of them it is depends on the application rather than on the transport. AgencyZero drains its persistence layer and hands over to a restart supervisor; a plain host re-executes itself; a headless one has nothing to relaunch and says so.

This is where that answer is registered. It lives beside the vocabulary rather than inside a host, because more than one host serves the same request: the Tauri runtime does it for a window today, and an embedder that drives a browser in process will do it for that browser next. It used to live in izumo, which meant an application registered a handler for an inspection service through a window runtime, and named the protocol’s types through that runtime’s re-export of this crate. Depending on a renderer to answer “restart yourself” is the edge this removes.

Nothing here needs a feature. The handler is one Arc and a lock, and the types it names are the vocabulary, so a consumer that registers one pays serde and nothing else: no engine, no socket, no window.

§One per process

Deliberately global, and deliberately last-writer-wins. A process has one lifecycle, so a second registration is a second opinion about the same question rather than a second subject to ask it about. Registering from a test therefore disturbs any other test in the same binary that reads it; clear_lifecycle_handler exists so such a test can put the process back.

Functions§

clear_lifecycle_handler
Forget the installed handler, leaving the host’s own behaviour.
lifecycle_handler
The installed handler, if an embedder installed one.
set_lifecycle_handler
Install the embedder’s answer to Relaunch and Quit.

Type Aliases§

LifecycleHandler
What an embedder installs to answer a lifecycle request.