summaryrefslogtreecommitdiffstats
path: root/src/mount_help.rs
blob: 9155d9a4db4913686708e1a540c983f2573466e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use anyhow::Result;

use crate::password::PasswordHolder;

/// Bunch of methods used to mount / unmount a block device or a device image file.
pub trait MountHelper {
    /// Parameters used to `sudo mkdir mountpoint`
    fn format_mkdir_parameters(&self, username: &str) -> [String; 3];

    /// Parameters used to mount the device
    fn format_mount_parameters(&mut self, username: &str) -> Vec<String>;

    /// Parameters used to umount the device
    fn format_umount_parameters(&self, username: &str) -> Vec<String>;

    /// True if the device is mounted
    fn is_mounted(&self) -> bool;

    /// Mount the device
    fn mount(&mut self, username: &str, password: &mut PasswordHolder) -> Result<bool>;

    /// Unmount the device
    fn umount(&mut self, username: &str, password: &mut PasswordHolder) -> Result<bool>;

    /// String representation of the device
    fn as_string(&self) -> Result<String>;

    fn device_name(&self) -> Result<String>;
}