Struct libblkid_rs::BlkidPartlist
source · pub struct BlkidPartlist(/* private fields */);
Expand description
A handle for traversing a list of partitions.
Implementations§
source§impl BlkidPartlist
impl BlkidPartlist
sourcepub fn number_of_partitions(&mut self) -> Result<c_int>
pub fn number_of_partitions(&mut self) -> Result<c_int>
Get the number of partitions in the list.
Examples found in repository?
examples/is_owned.rs (line 44)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
fn main() -> Result<(), Box<dyn Error>> {
let path = env::args()
.nth(1)
.ok_or_else(|| ExampleError::new("Path of device to check required as argument"))?;
let mut probe = BlkidProbe::new_from_filename(Path::new(&path))?;
probe.enable_superblocks(true)?;
probe.enable_partitions(true)?;
probe.do_safeprobe()?;
let partitions = probe
.get_partitions()
.and_then(|mut list| list.number_of_partitions());
let detected_use = probe.lookup_value("TYPE");
if partitions.as_ref().map(|num| *num > 0).unwrap_or(false) || detected_use.is_ok() {
println!("In use");
if let Ok(num) = partitions {
println!("{num} partitions found on block device");
}
if let Ok(ty) = detected_use {
println!("Device determined to be of type {ty}");
}
} else {
println!("Free");
}
Ok(())
}
sourcepub fn get_table(&mut self) -> Result<BlkidParttable>
pub fn get_table(&mut self) -> Result<BlkidParttable>
Get the partition table for a list of partitions.
sourcepub fn get_partition(&mut self, index: c_int) -> Result<BlkidPartition>
pub fn get_partition(&mut self, index: c_int) -> Result<BlkidPartition>
Get a partition at the given index of the list.
sourcepub fn get_partition_by_partno(&mut self, num: c_int) -> Result<BlkidPartition>
pub fn get_partition_by_partno(&mut self, num: c_int) -> Result<BlkidPartition>
Get a partition by the number listed in the partition table. Correctly handles “out-of-order” partition tables.
sourcepub fn get_partition_by_devno(
&mut self,
dev: &BlkidDevno
) -> Result<BlkidPartition>
pub fn get_partition_by_devno( &mut self, dev: &BlkidDevno ) -> Result<BlkidPartition>
Get a partition using the device number of a partition.
Auto Trait Implementations§
impl Freeze for BlkidPartlist
impl RefUnwindSafe for BlkidPartlist
impl !Send for BlkidPartlist
impl !Sync for BlkidPartlist
impl Unpin for BlkidPartlist
impl UnwindSafe for BlkidPartlist
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