pub struct BlockDevice {
pub name: String,
pub maj_min: MajMin,
pub rm: bool,
pub size: u64,
pub ro: bool,
pub device_type: DeviceType,
pub mountpoints: Vec<Option<String>>,
pub children: Option<Vec<BlockDevice>>,
}Expand description
Represents a block device as output by lsblk.
Note that the children field is optional, as some devices might not have any nested children.
§Field Details
name: The device name.maj_min: The device’s major and minor numbers. (Renamed from the JSON field “maj:min”)rm: Whether the device is removable.size: The device size.ro: Whether the device is read-only.device_type: The device type (renamed from the reserved keyword “type”).mountpoints: A vector of mountpoints for the device. Uses a custom deserializer to support both single and multiple mountpoints.children: Optional nested block devices.
Fields§
§name: StringThe name of the block device.
maj_min: MajMinThe major and minor numbers of the block device.
This field corresponds to the JSON field "maj:min".
rm: boolIndicates if the device is removable.
size: u64The size of the block device in bytes.
ro: boolIndicates if the device is read-only.
device_type: DeviceTypeThe type of the block device.
The JSON field is "type", which is a reserved keyword in Rust. It is renamed to device_type.
mountpoints: Vec<Option<String>>The mountpoints of the device.
Uses a custom deserializer to handle both a single mountpoint (possibly null) and an array of mountpoints.
children: Option<Vec<BlockDevice>>Optional nested children block devices.
Implementations§
Source§impl BlockDevice
impl BlockDevice
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Returns true if this device has any children.
Sourcepub fn children_iter(&self) -> impl Iterator<Item = &BlockDevice>
pub fn children_iter(&self) -> impl Iterator<Item = &BlockDevice>
Returns an iterator over the children of this device.
Returns an empty iterator if the device has no children.
Sourcepub fn find_child(&self, name: &str) -> Option<&BlockDevice>
pub fn find_child(&self, name: &str) -> Option<&BlockDevice>
Finds a direct child device by name.
Returns None if no child with the given name exists.
Sourcepub fn active_mountpoints(&self) -> Vec<&str>
pub fn active_mountpoints(&self) -> Vec<&str>
Returns all non-null mountpoints for this device.
Sourcepub fn is_mounted(&self) -> bool
pub fn is_mounted(&self) -> bool
Returns true if this device has at least one mountpoint.
Sourcepub fn is_system(&self) -> bool
pub fn is_system(&self) -> bool
Determines if this block device or any of its recursive children has a mountpoint of /,
indicating a system mount.
Sourcepub fn is_partition(&self) -> bool
pub fn is_partition(&self) -> bool
Returns true if this device is a partition.
Trait Implementations§
Source§impl Clone for BlockDevice
impl Clone for BlockDevice
Source§fn clone(&self) -> BlockDevice
fn clone(&self) -> BlockDevice
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more