Skip to main content

compute_device_label

Function compute_device_label 

Source
pub fn compute_device_label(
    target: &HardwareDevice,
    all_devices: &[HardwareDevice],
    nicknames: &HashMap<String, String>,
) -> String
Expand description

Compute the display label for a single device given the full device list + nickname map. The rule:

  1. If a nickname is set for this key, the label IS the nickname.
  2. Otherwise, if another un-nicknamed device shares this model string, append a location-derived suffix (“(payload after the key’s scheme prefix)”) so the user can tell them apart.
  3. Otherwise, the bare model string.

Both the daemon (SensorInfo.device_label decoration) and the GUI (HardwareModel’s page-title rendering) call this so they can never disagree on what a device is named.