Files
BitLogger/docs/api/color-mode-label.md
Nanaloveyuki 25a6a973d2 πŸ“ Update More API Document
2026-05-20 11:37:49 +08:00

1.6 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
color-mode-label api formatter 20260520 Convert a ColorMode value into its stable string label.
color
formatter
label
public

Color-mode-label

Convert ColorMode into its stable string label. This helper is useful for diagnostics, tests, and config inspection output that should mirror the built-in color mode names.

Interface

pub fn color_mode_label(mode : ColorMode) -> String {

input

  • mode : ColorMode - Color mode enum value to label.

output

  • String - Stable label such as never, auto, or always.

Explanation

Detailed rules explaining key parameters and behaviors

  • The returned strings match the built-in color mode vocabulary.
  • This helper is presentation-oriented and does not by itself enable or disable color rendering.
  • It is useful when tests or diagnostics should expose the configured color policy clearly.

How to Use

Here are some specific examples provided.

When Need A Readable Color Mode Name

When config or test output should include the current color policy:

let label = color_mode_label(ColorMode::Always)

In this example, label becomes "always".

Error Case

e.g.:

  • There is no failure path for valid ColorMode values.

  • If code needs rendering behavior rather than display text, the enum value itself is usually more useful than the label string.

Notes

  1. This helper is mostly useful for readable inspection and assertions.

  2. It is a natural companion to color_support_label(...).