pub struct BlkidPartlist<'a>(/* private fields */);Expand description
A handle for traversing a list of partitions.
Implementations§
Source§impl<'a> BlkidPartlist<'a>
impl<'a> BlkidPartlist<'a>
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)
32fn main() -> Result<(), Box<dyn Error>> {
33 let path = env::args()
34 .nth(1)
35 .ok_or_else(|| ExampleError::new("Path of device to check required as argument"))?;
36
37 let mut probe = BlkidProbe::new_from_filename(Path::new(&path))?;
38 probe.enable_superblocks(true)?;
39 probe.enable_partitions(true)?;
40 probe.do_safeprobe()?;
41
42 let partitions = probe
43 .get_partitions()
44 .and_then(|mut list| list.number_of_partitions());
45 let detected_use = probe.lookup_value("TYPE");
46
47 if partitions.as_ref().map(|num| *num > 0).unwrap_or(false) || detected_use.is_ok() {
48 println!("In use");
49 if let Ok(num) = partitions {
50 println!("{num} partitions found on block device");
51 }
52 if let Ok(ty) = detected_use {
53 println!("Device determined to be of type {ty}");
54 }
55 } else {
56 println!("Free");
57 }
58
59 Ok(())
60}Sourcepub fn get_table(&mut self) -> Result<BlkidParttable<'a>>
pub fn get_table(&mut self) -> Result<BlkidParttable<'a>>
Get the partition table for a list of partitions.
Sourcepub fn get_partition(&mut self, index: c_int) -> Result<BlkidPartition<'a>>
pub fn get_partition(&mut self, index: c_int) -> Result<BlkidPartition<'a>>
Get a partition at the given index of the list.
Sourcepub fn get_partition_by_partno(
&mut self,
num: c_int,
) -> Result<BlkidPartition<'a>>
pub fn get_partition_by_partno( &mut self, num: c_int, ) -> Result<BlkidPartition<'a>>
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<'a>>
pub fn get_partition_by_devno( &mut self, dev: &BlkidDevno, ) -> Result<BlkidPartition<'a>>
Get a partition using the device number of a partition.
Auto Trait Implementations§
impl<'a> Freeze for BlkidPartlist<'a>
impl<'a> RefUnwindSafe for BlkidPartlist<'a>
impl<'a> !Send for BlkidPartlist<'a>
impl<'a> !Sync for BlkidPartlist<'a>
impl<'a> Unpin for BlkidPartlist<'a>
impl<'a> UnwindSafe for BlkidPartlist<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more