pub struct PartitionIdentifiers {
pub id: Option<String>,
pub label: Option<String>,
pub part_label: Option<String>,
pub part_uuid: Option<String>,
pub path: Option<String>,
pub uuid: Option<String>,
}
Expand description
A collection of all discoverable identifiers for a partition.
Fields§
§id: Option<String>
§label: Option<String>
§part_label: Option<String>
§part_uuid: Option<String>
§path: Option<String>
§uuid: Option<String>
Implementations§
Source§impl PartitionIdentifiers
impl PartitionIdentifiers
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> PartitionIdentifiers
pub fn from_path<P: AsRef<Path>>(path: P) -> PartitionIdentifiers
Fetches all discoverable identifiers for a partition by the path to that partition.
Examples found in repository?
examples/example.rs (line 19)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 61 62 63 64 65
fn main() {
let mut args = env::args().skip(1);
match args.next() {
Some(arg) => match arg.as_str() {
"from-path" => {
let mut first = true;
for device in args {
if !first {
println!()
}
first = false;
println!("{}:", device);
println!("{:#?}", PartitionIdentifiers::from_path(device));
}
}
"by-id" => {
for id in args {
let var = PartitionID::new_id(id.clone());
println!("{}: {:?}", id, var.get_device_path());
}
}
"by-uuid" => {
for id in args {
let var = PartitionID::new_uuid(id.clone());
println!("{}: {:?}", id, var.get_device_path());
}
}
"by-partuuid" => {
for id in args {
let var = PartitionID::new_partuuid(id.clone());
println!("{}: {:?}", id, var.get_device_path());
}
}
"detect-by" => {
for id in args {
let id = match PartitionID::from_disk_by_path(&id) {
Ok(id) => id,
Err(why) => {
eprintln!("{}: {}", id, why);
exit(1);
}
};
println!("{:?} = {:?}", id, id.get_device_path());
}
}
_ => {
eprintln!(
"invalid subcommand: valid commansd: [from-path, by-uuid, by-partuuid, ]"
);
exit(1);
}
},
None => {
eprintln!("must give subcommand: [from-path, by-uuid, by-partuuid, ]");
exit(1);
}
}
}
Sourcepub fn matches(&self, id: &PartitionID) -> bool
pub fn matches(&self, id: &PartitionID) -> bool
Checks if the given identity matches one of the available identifiers.
Trait Implementations§
Source§impl Clone for PartitionIdentifiers
impl Clone for PartitionIdentifiers
Source§fn clone(&self) -> PartitionIdentifiers
fn clone(&self) -> PartitionIdentifiers
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PartitionIdentifiers
impl Debug for PartitionIdentifiers
Source§impl Default for PartitionIdentifiers
impl Default for PartitionIdentifiers
Source§fn default() -> PartitionIdentifiers
fn default() -> PartitionIdentifiers
Returns the “default value” for a type. Read more
Source§impl Hash for PartitionIdentifiers
impl Hash for PartitionIdentifiers
Source§impl PartialEq for PartitionIdentifiers
impl PartialEq for PartitionIdentifiers
impl StructuralPartialEq for PartitionIdentifiers
Auto Trait Implementations§
impl Freeze for PartitionIdentifiers
impl RefUnwindSafe for PartitionIdentifiers
impl Send for PartitionIdentifiers
impl Sync for PartitionIdentifiers
impl Unpin for PartitionIdentifiers
impl UnwindSafe for PartitionIdentifiers
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