Device

Trait Device 

Source
pub trait Device:
    Send
    + Sync
    + 'static
    + Debug
    + Any {
    // Required methods
    fn capacity(&self) -> usize;
    fn allocated(&self) -> usize;
    fn create_partition(&self, size: usize) -> Result<Arc<dyn Partition>>;
    fn partitions(&self) -> usize;
    fn partition(&self, id: u32) -> Arc<dyn Partition>;
    fn statistics(&self) -> &Arc<Statistics>;

    // Provided method
    fn free(&self) -> usize { ... }
}
Expand description

Device trait.

Required Methods§

Source

fn capacity(&self) -> usize

Get the capacity of the device.

NOTE: capacity must be 4K aligned.

Source

fn allocated(&self) -> usize

Get the allocated space in the device.

Source

fn create_partition(&self, size: usize) -> Result<Arc<dyn Partition>>

Create a new partition with the given size.

NOTE:

  • Allocating partition may consume more space than requested.
  • size must be 4K aligned.
Source

fn partitions(&self) -> usize

Get the number of partitions in the device.

Source

fn partition(&self, id: u32) -> Arc<dyn Partition>

Get the partition with given id in the device.

Source

fn statistics(&self) -> &Arc<Statistics>

Get the statistics of the device this partition belongs to.

Provided Methods§

Source

fn free(&self) -> usize

Get the free space in the device.

Implementors§