fm/modes/utils/
mount_help.rs

1use anyhow::Result;
2
3use crate::modes::PasswordHolder;
4
5/// Bunch of methods used to mount / unmount a block device or a device image file.
6pub trait MountCommands {
7    /// True if the device is mounted
8    fn is_mounted(&self) -> bool;
9
10    /// Mount the device
11    ///
12    /// # Errors
13    ///
14    /// It may fail if mounting returns an error
15    fn mount(&mut self, username: &str, password: &mut PasswordHolder) -> Result<bool>;
16
17    /// Unmount the device
18    ///
19    /// # Errors
20    ///
21    /// It may fail if unmounting returns an error
22    fn umount(&mut self, username: &str, password: &mut PasswordHolder) -> Result<bool>;
23}
24
25/// Parameters used to create the commands : mkdir, mount & umount.
26pub trait MountParameters {
27    /// Parameters used to `sudo mkdir mountpoint`
28    fn mkdir_parameters(&self, username: &str) -> [String; 3];
29
30    /// Parameters used to mount the device
31    fn mount_parameters(&self, username: &str) -> Vec<String>;
32
33    /// Parameters used to umount the device
34    fn umount_parameters(&self, username: &str) -> Vec<String>;
35}