Stringify-async-runtime-state
Serialize AsyncRuntimeState into JSON text. This helper is the most direct reporting path for async runtime mode and background worker capability.
Interface
pub fn stringify_async_runtime_state(
state : AsyncRuntimeState,
pretty~ : Bool = false,
) -> String {}input
state : AsyncRuntimeState- Runtime capability snapshot to serialize.pretty : Bool- Whether JSON should be pretty-printed.
output
String- Serialized JSON text for the runtime state.
Explanation
Detailed rules explaining key parameters and behaviors
pretty=falsereturns compact JSON.pretty=truereturns indented JSON for human diagnostics.- This helper is built on top of
async_runtime_state_to_json(...). - Internally it serializes the
JsonValueresult with@json_parser.stringify(...)or@json_parser.stringify_pretty(value, 2), so the text form stays aligned with the structured runtime-state export helper. - The compact form matches the tested snapshot shape such as
{"mode":"native_worker","background_worker":true}. - It is well-suited for startup banners, support reports, and target capability logs.
How to Use
Here are some specific examples provided.
When Need Human-readable Runtime Diagnostics
When capability information should be printed during startup:
println(stringify_async_runtime_state(async_runtime_state(), pretty=true))In this example, the runtime state is emitted in a readable form.
When Need Compact Capability Logs
When runtime info should stay small in structured logs:
let text = stringify_async_runtime_state(async_runtime_state())In this example, compact JSON is returned without extra formatting.
Error Case
e.g.:
If callers need a JSON value rather than text, they should use
async_runtime_state_to_json(...)instead.If more complete async logger diagnostics are required, this helper should be replaced with
stringify_async_logger_state(...).
Notes
The compact output uses the same canonical
modelabels asasync_runtime_mode_label(...).This helper is the direct text form of the same two-field runtime snapshot exported by
async_runtime_state_to_json(...).Use
async_runtime_state_to_json(...)when the next consumer still needs aJsonValuefor composition before final stringification.