Files
BitLogger/docs/api/stringify-async-runtime-state.md
T
2026-05-12 13:47:04 +08:00

1.9 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
stringify-async-runtime-state api async 20260512 Serialize AsyncRuntimeState into compact or pretty JSON text for diagnostics and startup reporting.
async
state
stringify
public

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=false returns compact JSON.
  • pretty=true returns indented JSON for human diagnostics.
  • This helper is built on top of async_runtime_state_to_json(...).
  • 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(...).