device_names.rs
1 /// Pre-allocated device name storage to avoid String allocations 2 /// These are used instead of "Device Name".to_string() in hot paths 3 use arrayvec::ArrayString; 4 5 /// Get pre-formatted exhaust fan name (no allocation) 6 #[allow(dead_code)] 7 pub fn exhaust_fan_name() -> ArrayString<32> { 8 let mut name = ArrayString::new(); 9 name.push_str("Exhaust Fan"); 10 name 11 } 12 13 /// Get pre-formatted circulation fan name (no allocation) 14 #[allow(dead_code)] 15 pub fn circulation_fan_name() -> ArrayString<32> { 16 let mut name = ArrayString::new(); 17 name.push_str("Circulation Fan"); 18 name 19 } 20 21 /// Get pre-formatted heater name (no allocation) 22 #[allow(dead_code)] 23 pub fn heater_name() -> ArrayString<32> { 24 let mut name = ArrayString::new(); 25 name.push_str("Heater"); 26 name 27 } 28 29 /// Get pre-formatted air purifier name (no allocation) 30 #[allow(dead_code)] 31 pub fn air_purifier_name() -> ArrayString<32> { 32 let mut name = ArrayString::new(); 33 name.push_str("Air Purifier"); 34 name 35 } 36 37 /// Build full hostname from settings (single allocation) 38 /// Format: "{hostname}-{device_id}" 39 pub fn build_hostname(hostname: &str, device_id: &str) -> ArrayString<64> { 40 let mut full_hostname = ArrayString::new(); 41 full_hostname.push_str(hostname); 42 full_hostname.push('-'); 43 full_hostname.push_str(device_id); 44 full_hostname 45 }