fn collect_available_ports(available_set: &mut HashMap<String, String>) {
  if let Ok(avail_ports) = available_ports() {
    for port in avail_ports {

      match port.port_type {
        SerialPortType::UsbPort(info) => {
          if !available_set.contains_key(&port.port_name) {
            //add to list
            let sn_str = info.serial_number.unwrap_or(port.port_name.clone());
            // println!("sn_str: {}", sn_str);
            available_set.insert(port.port_name.clone(), sn_str);
            // println!("adding: {} {}", port.port_name, sn_str);

            // println!("    Type: USB");
            // println!("    VID:{:04x} PID:{:04x}", info.vid, info.pid);
            // println!(
            //   "     Serial Number: {}",
            //   info.serial_number.as_ref().map_or("", String::as_str)
            // );
            // println!(
            //   "      Manufacturer: {}",
            //   info.manufacturer.as_ref().map_or("", String::as_str)
            // );
            // println!(
            //   "           Product: {}",
            //   info.product.as_ref().map_or("", String::as_str)
            // );

          }
        }
        _ => {
          //println!("   Ignored Port: {}", port.port_name);
        }

      }

    }
  }
}
/// Collect a list of ports that we're interested in
Collect a list of ports that we're interested in
Collect a list of ports that we ' re interested in
fn collect_available_ports(available_set: &mut HashMap<String, String>) {
  if let Ok(avail_ports) = available_ports() {
    for port in avail_ports {
      match port.port_type {
        SerialPortType::UsbPort(info) => {
          if !available_set.contains_key(&port.port_name) {
            //add to list
            let sn_str = info.serial_number.unwrap_or(port.port_name.clone());
            // println!("sn_str: {}", sn_str);
            available_set.insert(port.port_name.clone(), sn_str);
            // println!("adding: {} {}", port.port_name, sn_str);
            // println!("    Type: USB");
            // println!("    VID:{:04x} PID:{:04x}", info.vid, info.pid);
            // println!(
            //   "     Serial Number: {}",
            //   info.serial_number.as_ref().map_or("", String::as_str)
            // );
            // println!(
            //   "      Manufacturer: {}",
            //   info.manufacturer.as_ref().map_or("", String::as_str)
            // );
            // println!(
            //   "           Product: {}",
            //   info.product.as_ref().map_or("", String::as_str)
            // );
          }
        }
        _ => {
          //println!("   Ignored Port: {}", port.port_name);
        }
      }
    }
  }
}
fn collect_available_ports ( available_set : & mut HashMap < String , String > ) { if let Ok ( avail_ports ) = available_ports ( ) { for port in avail_ports { match port . port_type { SerialPortType :: UsbPort ( info ) => { if ! available_set . contains_key ( & port . port_name ) { //add to list let sn_str = info . serial_number . unwrap_or ( port . port_name . clone ( ) ) ; // println!("sn_str: {}", sn_str); available_set . insert ( port . port_name . clone ( ) , sn_str ) ; // println!("adding: {} {}", port.port_name, sn_str); // println!("    Type: USB"); // println!("    VID:{:04x} PID:{:04x}", info.vid, info.pid); // println!( //   "     Serial Number: {}", //   info.serial_number.as_ref().map_or("", String::as_str) // ); // println!( //   "      Manufacturer: {}", //   info.manufacturer.as_ref().map_or("", String::as_str) // ); // println!( //   "           Product: {}", //   info.product.as_ref().map_or("", String::as_str) // ); } } _ => { //println!("   Ignored Port: {}", port.port_name); } } } } }
Collect a list of ports that we're interested in
Collect a list of ports that we ' re interested in
available_set
&mut HashMap<String, String>
available_set
&mut HashMap<String, String>