pub struct ReadOnlyDevice<H: ReadObjectHandle> { /* private fields */ }
Expand description
Allows using anything that implements ReadObjectHandle
as a read-only storage Device
.
Implementations§
Source§impl<H: ReadObjectHandle> ReadOnlyDevice<H>
impl<H: ReadObjectHandle> ReadOnlyDevice<H>
Trait Implementations§
Source§impl<H: ReadObjectHandle> Device for ReadOnlyDevice<H>
impl<H: ReadObjectHandle> Device for ReadOnlyDevice<H>
Source§fn 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.
Blocks until enough capacity is available in the buffer.
Source§fn block_size(&self) -> u32
fn block_size(&self) -> u32
Returns the block size of the device. Buffers are aligned to block-aligned chunks.
Source§fn block_count(&self) -> u64
fn block_count(&self) -> u64
Returns the number of blocks of the device.
Source§fn read_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: MutableBufferRef<'life1>,
_read_opts: ReadOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: MutableBufferRef<'life1>,
_read_opts: ReadOptions,
) -> 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|.
Source§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 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.
Source§fn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Returns whether the device is read-only.
Source§fn supports_trim(&self) -> bool
fn supports_trim(&self) -> bool
Returns whether the device supports trim.
Source§fn write_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
_offset: u64,
_buffer: BufferRef<'life1>,
_write_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>,
_write_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|.
Source§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 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.
Source§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 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|.
Source§fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: MutableBufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Fills |buffer| with blocks read from |offset|.
Source§fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
offset: u64,
buffer: BufferRef<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Writes the contents of |buffer| to the device at |offset|.
Source§fn reopen(&self, _read_only: bool)
fn reopen(&self, _read_only: bool)
Reopens the device, making it usable again. (Only implemented for testing devices.)
Auto Trait Implementations§
impl<H> Freeze for ReadOnlyDevice<H>where
H: Freeze,
impl<H> RefUnwindSafe for ReadOnlyDevice<H>where
H: RefUnwindSafe,
impl<H> Send for ReadOnlyDevice<H>
impl<H> Sync for ReadOnlyDevice<H>
impl<H> Unpin for ReadOnlyDevice<H>where
H: Unpin,
impl<H> UnwindSafe for ReadOnlyDevice<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more