Struct BlockDevice

Source
pub struct BlockDevice {
    pub name: String,
    pub maj_min: String,
    pub rm: bool,
    pub size: String,
    pub ro: bool,
    pub device_type: String,
    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: String

The name of the block device.

§maj_min: String

The major and minor numbers of the block device.

This field corresponds to the JSON field "maj:min".

§rm: bool

Indicates if the device is removable.

§size: String

The size of the block device.

§ro: bool

Indicates if the device is read-only.

§device_type: String

The 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

Source

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.

Trait Implementations§

Source§

impl Debug for BlockDevice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BlockDevice

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BlockDevice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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>,

Source§

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>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,