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.Auto Trait Implementations§
impl Freeze for Mount
impl RefUnwindSafe for Mount
impl Send for Mount
impl Sync for Mount
impl Unpin for Mount
impl UnwindSafe for Mount
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more