pub struct BlkidPartlist(/* private fields */);
Expand description

A handle for traversing a list of partitions.

Implementations§

source§

impl BlkidPartlist

source

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(())
}
source

pub fn get_table(&mut self) -> Result<BlkidParttable>

Get the partition table for a list of partitions.

source

pub fn get_partition(&mut self, index: c_int) -> Result<BlkidPartition>

Get a partition at the given index of the list.

source

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.

source

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§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.