Attaches a new `drive` with `name`, which was instantiated with `uri`. The `name` must be valid and must not yet have been registered.
(&mut self, name: &str, uri: &str, drive: Box<dyn Drive>)
| 443 | /// |
| 444 | /// The `name` must be valid and must not yet have been registered. |
| 445 | fn attach(&mut self, name: &str, uri: &str, drive: Box<dyn Drive>) -> io::Result<()> { |
| 446 | let key = DriveKey::new(name)?; |
| 447 | if self.drives.contains_key(&key) { |
| 448 | return Err(io::Error::new( |
| 449 | io::ErrorKind::AlreadyExists, |
| 450 | format!("Drive '{}' is already mounted", name), |
| 451 | )); |
| 452 | } |
| 453 | let mounted_drive = MountedDrive { uri: uri.to_owned(), drive }; |
| 454 | self.drives.insert(DriveKey::new(name)?, mounted_drive); |
| 455 | Ok(()) |
| 456 | } |
| 457 | |
| 458 | /// Instantiates and attaches a new `drive` with `name` that points to `uri`. |
| 459 | /// |