pub struct Mount { /* private fields */ }
Expand description
Handle for managing a mounted file system.
Implementations§
source§impl Mount
impl Mount
sourcepub fn builder<'a>() -> MountBuilder<'a>
pub fn builder<'a>() -> MountBuilder<'a>
Creates a MountBuilder
for configuring a new mount.
use sys_mount::*;
fn main() -> std::io::Result<()> {
let _mount = Mount::builder()
.fstype("btrfs")
.data("subvol=@home")
.mount("/dev/sda1", "/home")?;
Ok(())
}
sourcepub fn new(source: impl AsRef<Path>, target: impl AsRef<Path>) -> Result<Mount>
pub fn new(source: impl AsRef<Path>, target: impl AsRef<Path>) -> Result<Mount>
Mounts the source device to the target path.
Attempts to automatically detect the filesystem of the source device.
For more flexibility, use Mount::builder
instead.
Errors
Errors if supported filesystems cannot be detected, or the mount fails.
sourcepub fn backing_loop_device(&self) -> Option<&Path>
pub fn backing_loop_device(&self) -> Option<&Path>
If the device was associated with a loopback device, that device’s path can be retrieved here.
sourcepub fn get_fstype(&self) -> &str
pub fn get_fstype(&self) -> &str
Describes the file system which this mount was mounted with.
This is useful in the event that the mounted device was mounted automatically.
sourcepub fn target_path(&self) -> &Path
pub fn target_path(&self) -> &Path
Return the path this mount was mounted on.
Trait Implementations§
source§impl Unmount for Mount
impl Unmount for Mount
source§fn unmount(&self, flags: UnmountFlags) -> Result<()>
fn unmount(&self, flags: UnmountFlags) -> Result<()>
Unmount this mount with the given
flags
. Read moresource§fn into_unmount_drop(self, flags: UnmountFlags) -> UnmountDrop<Self>where
Self: Sized,
fn into_unmount_drop(self, flags: UnmountFlags) -> UnmountDrop<Self>where
Self: Sized,
Upgrades
Self
into an UnmountDrop
, which will unmount the mount when it is dropped.