Struct Block

Source
pub struct Block { /* private fields */ }
Expand description

A block device in /sys/class/block

Implementations§

Source§

impl Block

Source

pub fn has_device(&self) -> bool

Examples found in repository?
examples/block.rs (line 6)
4fn main() -> io::Result<()> {
5    for block in Block::all()? {
6        if block.has_device() {
7            println!("Path: {:?}", block.path());
8            println!("  Model: {:?}", block.device_model());
9            println!("  Vendor: {:?}", block.device_vendor());
10            println!("  Rev: {:?}", block.device_rev());
11            println!("  Children: {:#?}", block.children());
12        }
13    }
14
15    Ok(())
16}
Source

pub fn children(&self) -> Result<Vec<Self>>

Examples found in repository?
examples/block.rs (line 11)
4fn main() -> io::Result<()> {
5    for block in Block::all()? {
6        if block.has_device() {
7            println!("Path: {:?}", block.path());
8            println!("  Model: {:?}", block.device_model());
9            println!("  Vendor: {:?}", block.device_vendor());
10            println!("  Rev: {:?}", block.device_rev());
11            println!("  Children: {:#?}", block.children());
12        }
13    }
14
15    Ok(())
16}
Source

pub fn parent_device(&self) -> Option<Block>

Source

pub fn slaves( &self, ) -> Option<Result<Box<dyn Iterator<Item = Result<PathBuf>>>>>

Logical devices have their parent device(s) listed here.

For example:

  • dm-4 has a slave of dm-0
  • dm-0 has a slave of sda3
  • sda3 does not have any slaves
Source

pub fn alignment_offset(&self) -> Result<u64>

Source

pub fn capability(&self) -> Result<u8>

Source

pub fn dev(&self) -> Result<String>

Source

pub fn discard_alignment(&self) -> Result<u64>

Source

pub fn events(&self) -> Result<u64>

Source

pub fn events_async(&self) -> Result<u64>

Source

pub fn events_poll_msecs(&self) -> Result<u64>

Source

pub fn ext_range(&self) -> Result<u64>

Source

pub fn hidden(&self) -> Result<u8>

Source

pub fn inflight(&self) -> Result<String>

Source

pub fn partition(&self) -> Result<u8>

Source

pub fn range(&self) -> Result<u64>

Source

pub fn removable(&self) -> Result<u8>

Source

pub fn ro(&self) -> Result<u8>

Source

pub fn size(&self) -> Result<u64>

Source

pub fn start(&self) -> Result<u64>

Source

pub fn stat(&self) -> Result<u8>

Source

pub fn subsystem(&self) -> Result<u8>

Source

pub fn uevent(&self) -> Result<String>

Source

pub fn device_blocked(&self) -> Result<u8>

Source

pub fn device_busy(&self) -> Result<u8>

Source

pub fn device_model(&self) -> Result<String>

Examples found in repository?
examples/block.rs (line 8)
4fn main() -> io::Result<()> {
5    for block in Block::all()? {
6        if block.has_device() {
7            println!("Path: {:?}", block.path());
8            println!("  Model: {:?}", block.device_model());
9            println!("  Vendor: {:?}", block.device_vendor());
10            println!("  Rev: {:?}", block.device_rev());
11            println!("  Children: {:#?}", block.children());
12        }
13    }
14
15    Ok(())
16}
Source

pub fn device_rev(&self) -> Result<String>

Examples found in repository?
examples/block.rs (line 10)
4fn main() -> io::Result<()> {
5    for block in Block::all()? {
6        if block.has_device() {
7            println!("Path: {:?}", block.path());
8            println!("  Model: {:?}", block.device_model());
9            println!("  Vendor: {:?}", block.device_vendor());
10            println!("  Rev: {:?}", block.device_rev());
11            println!("  Children: {:#?}", block.children());
12        }
13    }
14
15    Ok(())
16}
Source

pub fn device_state(&self) -> Result<String>

Source

pub fn device_vendor(&self) -> Result<String>

Examples found in repository?
examples/block.rs (line 9)
4fn main() -> io::Result<()> {
5    for block in Block::all()? {
6        if block.has_device() {
7            println!("Path: {:?}", block.path());
8            println!("  Model: {:?}", block.device_model());
9            println!("  Vendor: {:?}", block.device_vendor());
10            println!("  Rev: {:?}", block.device_rev());
11            println!("  Children: {:#?}", block.children());
12        }
13    }
14
15    Ok(())
16}
Source

pub fn queue_add_random(&self) -> Result<u64>

Source

pub fn queue_chunk_sectors(&self) -> Result<u64>

Source

pub fn queue_dax(&self) -> Result<u64>

Source

pub fn queue_discard_granularity(&self) -> Result<u64>

Source

pub fn queue_discard_max_bytes(&self) -> Result<u64>

Source

pub fn queue_discard_max_hw_bytes(&self) -> Result<u64>

Source

pub fn queue_discard_zeroes_data(&self) -> Result<u64>

Source

pub fn queue_fua(&self) -> Result<u64>

Source

pub fn queue_hw_sector_size(&self) -> Result<u64>

Source

pub fn queue_io_poll(&self) -> Result<u64>

Source

pub fn queue_io_poll_delay(&self) -> Result<u64>

Source

pub fn queue_iostats(&self) -> Result<u64>

Source

pub fn queue_logical_block_size(&self) -> Result<u64>

Source

pub fn queue_max_discard_segments(&self) -> Result<u64>

Source

pub fn queue_max_hw_sectors_kb(&self) -> Result<u64>

Source

pub fn queue_max_integrity_segments(&self) -> Result<u64>

Source

pub fn queue_max_sectors_kb(&self) -> Result<u64>

Source

pub fn queue_max_segment_size(&self) -> Result<u64>

Source

pub fn queue_max_segments(&self) -> Result<u64>

Source

pub fn queue_minimum_io_size(&self) -> Result<u64>

Source

pub fn queue_nomerges(&self) -> Result<u64>

Source

pub fn queue_nr_requests(&self) -> Result<u64>

Source

pub fn queue_optimal_io_size(&self) -> Result<u64>

Source

pub fn queue_physical_block_size(&self) -> Result<u64>

Source

pub fn queue_read_ahead_kb(&self) -> Result<u64>

Source

pub fn queue_rotational(&self) -> Result<u8>

Source

pub fn queue_rq_affinity(&self) -> Result<u64>

Source

pub fn queue_scheduler(&self) -> Result<BlockScheduler>

Source

pub fn queue_write_cache(&self) -> Result<String>

Source

pub fn queue_write_same_max_bytes(&self) -> Result<u64>

Source

pub fn queue_write_zeroes_max_bytes(&self) -> Result<u64>

Source

pub fn queue_zoned(&self) -> Result<String>

Source

pub fn queue_iosched_back_seek_max(&self) -> Result<u64>

Source

pub fn queue_iosched_back_seek_penalty(&self) -> Result<u64>

Source

pub fn queue_iosched_fifo_expire_async(&self) -> Result<u64>

Source

pub fn queue_iosched_fifo_expire_sync(&self) -> Result<u64>

Source

pub fn queue_iosched_group_idle(&self) -> Result<u64>

Source

pub fn queue_iosched_group_idle_us(&self) -> Result<u64>

Source

pub fn queue_iosched_low_latency(&self) -> Result<u8>

Source

pub fn queue_iosched_quantum(&self) -> Result<u64>

Source

pub fn queue_iosched_slice_async(&self) -> Result<u64>

Source

pub fn queue_iosched_slice_async_rq(&self) -> Result<u64>

Source

pub fn queue_iosched_slice_async_us(&self) -> Result<u64>

Source

pub fn queue_iosched_slice_idle(&self) -> Result<u8>

Source

pub fn queue_iosched_slice_idle_us(&self) -> Result<u64>

Source

pub fn queue_iosched_slice_sync(&self) -> Result<u64>

Source

pub fn queue_iosched_slice_sync_us(&self) -> Result<u64>

Source

pub fn queue_iosched_target_latency(&self) -> Result<u64>

Source

pub fn queue_iosched_target_latency_us(&self) -> Result<u64>

Trait Implementations§

Source§

impl Clone for Block

Source§

fn clone(&self) -> Block

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 Block

Source§

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

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

impl Hash for Block

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Block

Source§

fn cmp(&self, other: &Block) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Block

Source§

fn eq(&self, other: &Block) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Block

Source§

fn partial_cmp(&self, other: &Block) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl SysClass for Block

Source§

fn class() -> &'static str

Return the class of the sys object, the name of a folder in `/sys/${base}``
Source§

unsafe fn from_path_unchecked(path: PathBuf) -> Self

Create a sys object from an absolute path without checking path for validity
Source§

fn path(&self) -> &Path

Return the path of the sys object
Source§

fn base() -> &'static str

Sets the base directory, which defaults to class.
Source§

fn dir() -> PathBuf

Return the path to the sys objects, the full path of a folder in /sys/class
Source§

fn from_path(path: &Path) -> Result<Self>

Create a sys object from a path, checking it for validity
Source§

fn all() -> Result<Vec<Self>>

Retrieve all of the object instances of a sys class
Source§

fn iter() -> Box<dyn Iterator<Item = Result<Self>>>
where Self: 'static,

Retrieve all of the object instances of a sys class, with a boxed iterator
Source§

fn new(id: &str) -> Result<Self>

Create a sys object by id, checking it for validity
Source§

fn id(&self) -> &str

Return the id of the sys object
Source§

fn read_file<P: AsRef<Path>>(&self, name: P) -> Result<String>

Read a file underneath the sys object
Source§

fn parse_file<F: FromStr, P: AsRef<Path>>(&self, name: P) -> Result<F>
where F::Err: Display,

Parse a number from a file underneath the sys object
Source§

fn trim_file<P: AsRef<Path>>(&self, name: P) -> Result<String>

Read a file underneath the sys object and trim whitespace
Source§

fn write_file<P: AsRef<Path>, S: AsRef<[u8]>>( &self, name: P, data: S, ) -> Result<()>

Write a file underneath the sys object
Source§

impl Eq for Block

Source§

impl StructuralPartialEq for Block

Auto Trait Implementations§

§

impl Freeze for Block

§

impl RefUnwindSafe for Block

§

impl Send for Block

§

impl Sync for Block

§

impl Unpin for Block

§

impl UnwindSafe for Block

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

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.