(&mut self, prefix: &str)
| 3734 | } |
| 3735 | |
| 3736 | fn next_device_name(&mut self, prefix: &str) -> DeviceManagerResult<String> { |
| 3737 | let start_id = self.device_id_cnt; |
| 3738 | loop { |
| 3739 | // Generate the temporary name. |
| 3740 | let name = format!("{}{}", prefix, self.device_id_cnt); |
| 3741 | // Increment the counter. |
| 3742 | self.device_id_cnt += Wrapping(1); |
| 3743 | // Check if the name is already in use. |
| 3744 | if !self.boot_id_list.contains(&name) |
| 3745 | && !self.device_tree.lock().unwrap().contains_key(&name) |
| 3746 | { |
| 3747 | return Ok(name); |
| 3748 | } |
| 3749 | |
| 3750 | if self.device_id_cnt == start_id { |
| 3751 | // We went through a full loop and there's nothing else we can |
| 3752 | // do. |
| 3753 | break; |
| 3754 | } |
| 3755 | } |
| 3756 | Err(DeviceManagerError::NoAvailableDeviceName) |
| 3757 | } |
| 3758 | |
| 3759 | fn add_passthrough_device( |
| 3760 | &mut self, |
no test coverage detected