mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 07:32:22 +00:00
1.8 KiB
1.8 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| async-runtime-mode-label | api | async | 20260512 | Convert AsyncRuntimeMode into a stable string label for logs, JSON, and diagnostics. |
|
Async-runtime-mode-label
Convert AsyncRuntimeMode into a stable string label. This helper is useful when runtime mode should be logged, serialized, or exposed through human-readable diagnostics.
Interface
pub fn async_runtime_mode_label(mode : AsyncRuntimeMode) -> String {}
input
mode : AsyncRuntimeMode- Runtime mode enum value.
output
String- Stable mode label such asnative_workerorcompatibility.
Explanation
Detailed rules explaining key parameters and behaviors
- The returned value is intended for diagnostics and stable output, not just debugging prints.
- It keeps mode serialization logic in one place.
- This helper is used by async runtime JSON helpers.
- Labels are more stable for telemetry and docs than ad hoc manual matching at call sites.
How to Use
Here are some specific examples provided.
When Need A Stable Log Label
When the mode should be included in structured or plain logs:
println(async_runtime_mode_label(async_runtime_mode()))
In this example, the label is directly usable in diagnostics.
When Build Custom Serialization
When callers want to embed the mode into their own payloads:
let label = async_runtime_mode_label(async_runtime_mode())
In this example, code gets a stable string without duplicating enum matching logic.
Error Case
e.g.:
-
This API assumes a valid
AsyncRuntimeModeinput and does not expose a normal runtime error path. -
If callers need the whole runtime object rather than a string label, use
async_runtime_state().