pub fn enumerate() -> Result<impl Iterator<Item = LidarName>, EnumerateError> {
        // Get all available serial ports
        let ports = serialport::available_ports().map_err(EnumerateError::AvailablePortsError)?;

        // Filter out all non-usb ports
        let usb_ports = ports.into_iter().filter_map(|port| match port.port_type {
            SerialPortType::UsbPort(usb_port) => Some((port.port_name, usb_port)),
            _ => None,
        });

        // Keep all CP210x uart bridges (the lidar doesn't have a specific vendor id but shows up as a generic CP210x uart bridge)
        let cp210_uart_brides = usb_ports.filter_map(|(port_name, usb_info)| {
            if usb_info.vid == CP210X_VID && usb_info.pid == CP210X_PID {
                Some(port_name)
            } else {
                None
            }
        });

        // Convert all cp210 bridges to LidarName
        let lidar_names = cp210_uart_brides.map(|port_name| LidarName(port_name));

        // Return the lidar names
        Ok(lidar_names)
    }
/// Returns all available LidarSensors that are connected to the computer
Returns all available LidarSensors that are connected to the computer
Returns all available LidarSensors that are connected to the computer
pub fn enumerate() -> Result<impl Iterator<Item = LidarName>, EnumerateError> {
        // Get all available serial ports
        let ports = serialport::available_ports().map_err(EnumerateError::AvailablePortsError)?;
        // Filter out all non-usb ports
        let usb_ports = ports.into_iter().filter_map(|port| match port.port_type {
            SerialPortType::UsbPort(usb_port) => Some((port.port_name, usb_port)),
            _ => None,
        });
        // Keep all CP210x uart bridges (the lidar doesn't have a specific vendor id but shows up as a generic CP210x uart bridge)
        let cp210_uart_brides = usb_ports.filter_map(|(port_name, usb_info)| {
            if usb_info.vid == CP210X_VID && usb_info.pid == CP210X_PID {
                Some(port_name)
            } else {
                None
            }
        });
        // Convert all cp210 bridges to LidarName
        let lidar_names = cp210_uart_brides.map(|port_name| LidarName(port_name));
        // Return the lidar names
        Ok(lidar_names)
    }
pub fn enumerate ( ) -> Result < impl Iterator < Item = LidarName > , EnumerateError > { // Get all available serial ports let ports = serialport :: available_ports ( ) . map_err ( EnumerateError :: AvailablePortsError ) ? ; // Filter out all non-usb ports let usb_ports = ports . into_iter ( ) . filter_map ( | port | match port . port_type { SerialPortType :: UsbPort ( usb_port ) => Some ( ( port . port_name , usb_port ) ) , _ => None , } ) ; // Keep all CP210x uart bridges (the lidar doesn't have a specific vendor id but shows up as a generic CP210x uart bridge) let cp210_uart_brides = usb_ports . filter_map ( | ( port_name , usb_info ) | { if usb_info . vid == CP210X_VID && usb_info . pid == CP210X_PID { Some ( port_name ) } else { None } } ) ; // Convert all cp210 bridges to LidarName let lidar_names = cp210_uart_brides . map ( | port_name | LidarName ( port_name ) ) ; // Return the lidar names Ok ( lidar_names ) }
Returns all available LidarSensors that are connected to the computer
Returns all available LidarSensors that are connected to the computer