fn to_identifier(state: &Mutex<State>, key: &str) -> Option<String> {
    // Compile regex inline because it is not ever expected to be a bottleneck
    let address_pattern = Regex::new(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$")
        .expect("Could not compile mac address regex pattern.");
    if address_pattern.is_match(key) {
        state
            .lock()
            .devices
            .values()
            .find(|device| device.0.address == key)
            .map(|device| device.0.identifier.to_string())
    } else {
        Some(key.to_string())
    }
}
// Find the identifier for a `RemoteDevice` based on a `key` that is either an identifier or an
// address.
// Returns `None` if the given address does not belong to a known device.
Find the identifier for a `RemoteDevice` based on a `key` that is either an identifier or an
address.
Returns `None` if the given address does not belong to a known device.
Find the identifier for a ` RemoteDevice ` based on a ` key ` that is either an identifier or an address . Returns ` None ` if the given address does not belong to a known device .
fn to_identifier(state: &Mutex<State>, key: &str) -> Option<String> {
    // Compile regex inline because it is not ever expected to be a bottleneck
    let address_pattern = Regex::new(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$")
        .expect("Could not compile mac address regex pattern.");
    if address_pattern.is_match(key) {
        state
            .lock()
            .devices
            .values()
            .find(|device| device.0.address == key)
            .map(|device| device.0.identifier.to_string())
    } else {
        Some(key.to_string())
    }
}
fn to_identifier ( state : & Mutex < State > , key : & str ) -> Option < String > { // Compile regex inline because it is not ever expected to be a bottleneck let address_pattern = Regex :: new ( r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$" ) . expect ( " " ) ; if address_pattern . is_match ( key ) { state . lock ( ) . devices . values ( ) . find ( | device | device . 0 . address == key ) . map ( | device | device . 0 . identifier . to_string ( ) ) } else { Some ( key . to_string ( ) ) } }
Find the identifier for a `RemoteDevice` based on a `key` that is either an identifier or an
address.
Find the identifier for a ` RemoteDevice ` based on a ` key ` that is either an identifier or an address .
state
&Mutex<State>
key
&str
state
&Mutex<State>
key
&str