Struct lsblk::BlockDevice

source ·
pub struct BlockDevice {
    pub name: String,
    pub diskseq: Option<String>,
    pub path: Option<String>,
    pub uuid: Option<String>,
    pub partuuid: Option<String>,
    pub label: Option<String>,
    pub partlabel: Option<String>,
    pub id: Option<String>,
}
Expand description

A representation of a block-device

Fields§

§name: String

the filename of the block-device.

If the drive is deemed to be storage by the kernel, this is usually prefixed by one of the followings:

  • sd
  • hd
  • vd
  • nvme
  • mmcblk
  • loop
§diskseq: Option<String>

The diskseq of the device as in /dev/disk/by-diskseq/.

§path: Option<String>

The path (not the filesystem!) of the device as in /dev/disk/by-path.

§uuid: Option<String>

The device UUID.

§partuuid: Option<String>

The UUID of a partition (not the same as device UUID).

§label: Option<String>

The label of the partition.

§partlabel: Option<String>

The partition label (not the same as label), as in /dev/disk/by-partlabel)

§id: Option<String>

The id of the device as in /dev/disk/by-id/.

Implementations§

source§

impl BlockDevice

source

pub fn list() -> Result<Vec<Self>, LsblkError>

List out all found block devices and populate all fields.

source

pub fn is_disk(&self) -> bool

Returns true if and only if the device is a storage disk and is not a partition.

source

pub fn is_part(&self) -> bool

Returns true if and only if the device is a partition.

The implementation currently is just:

self.uuid.is_some()

Trait Implementations§

source§

impl Clone for BlockDevice

source§

fn clone(&self) -> BlockDevice

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BlockDevice

source§

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

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

impl Default for BlockDevice

source§

fn default() -> BlockDevice

Returns the “default value” for a type. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.