pub trait Device: Send + Sync {
Show 16 methods
// Required methods
fn allocate_buffer(&self, size: usize) -> BufferFuture<'_> ⓘ;
fn block_size(&self) -> u32;
fn block_count(&self) -> u64;
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: MutableBufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn write_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
opts: WriteOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn trim<'life0, 'async_trait>(
&'life0 self,
range: Range<u64>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_read_only(&self) -> bool;
fn supports_trim(&self) -> bool;
// Provided methods
fn size(&self) -> u64 { ... }
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn reopen(&self, _read_only: bool) { ... }
fn snapshot(&self) -> Result<DeviceHolder, Error> { ... }
fn discard_random_since_last_flush(&self) -> Result<(), Error> { ... }
fn poison(&self) -> Result<(), Error> { ... }
}
Expand description
Device is an abstract representation of an underlying block device.
Required Methods§
Sourcefn allocate_buffer(&self, size: usize) -> BufferFuture<'_> ⓘ
fn allocate_buffer(&self, size: usize) -> BufferFuture<'_> ⓘ
Allocates a transfer buffer of at least |size| bytes for doing I/O with the device. The actual size of the buffer will be rounded up to a block-aligned size.
Sourcefn block_size(&self) -> u32
fn block_size(&self) -> u32
Returns the block size of the device. Buffers are aligned to block-aligned chunks.
Sourcefn block_count(&self) -> u64
fn block_count(&self) -> u64
Returns the number of blocks of the device.
Sourcefn read<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: MutableBufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: MutableBufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fills |buffer| with blocks read from |offset|.
Sourcefn write_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
opts: WriteOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
opts: WriteOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes the contents of |buffer| to the device at |offset|.
Sourcefn trim<'life0, 'async_trait>(
&'life0 self,
range: Range<u64>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn trim<'life0, 'async_trait>(
&'life0 self,
range: Range<u64>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Trims the given device |range|.
Sourcefn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Closes the block device. It is an error to continue using the device after this, but close itself is idempotent.
Sourcefn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Flush the device.
Sourcefn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Returns whether the device is read-only.
Sourcefn supports_trim(&self) -> bool
fn supports_trim(&self) -> bool
Returns whether the device supports trim.
Provided Methods§
Sourcefn write<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes the contents of |buffer| to the device at |offset|.
Sourcefn reopen(&self, _read_only: bool)
fn reopen(&self, _read_only: bool)
Reopens the device, making it usable again. (Only implemented for testing devices.)
Sourcefn snapshot(&self) -> Result<DeviceHolder, Error>
fn snapshot(&self) -> Result<DeviceHolder, Error>
Returns a snapshot of the device.
Sourcefn discard_random_since_last_flush(&self) -> Result<(), Error>
fn discard_random_since_last_flush(&self) -> Result<(), Error>
Discards random blocks since the last flush.