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§
Sourcefn create_partition(&self, size: usize) -> Result<Arc<dyn Partition>>
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.
sizemust be 4K aligned.
Sourcefn partitions(&self) -> usize
fn partitions(&self) -> usize
Get the number of partitions in the device.
Sourcefn partition(&self, id: u32) -> Arc<dyn Partition>
fn partition(&self, id: u32) -> Arc<dyn Partition>
Get the partition with given id in the device.
Sourcefn statistics(&self) -> &Arc<Statistics>
fn statistics(&self) -> &Arc<Statistics>
Get the statistics of the device this partition belongs to.