pub trait ResolveDevice {
// Required method
fn resolve_device(&self) -> Result<PathBuf>;
}Expand description
A trait for resolving the underlying block device of a file or path.
This trait is implemented for Path and File, allowing you to resolve
the block device using a consistent interface.
Required Methods§
Sourcefn resolve_device(&self) -> Result<PathBuf>
fn resolve_device(&self) -> Result<PathBuf>
Resolves the underlying block device path.
Returns the path to the block device (e.g., /dev/sda1, /dev/nvme0n1p1)
that contains the file or directory.
§Errors
Returns an io::Error if:
- The file/path cannot be accessed
- The device information cannot be retrieved
- The device cannot be mapped to a block device path
§Example
use blkpath::ResolveDevice;
use std::path::Path;
let path = Path::new("/home");
let device = path.resolve_device()?;
println!("Device: {}", device.display());