Skip to content

Commit 2f44a69

Browse files
00xcandreeaflorescu
authored andcommitted
blk: allow retrieving the backing object from StdIoBackend
Add three methods to retrieve the inner `B` from an `StdIoBackend`. This is useful to inspect or save the inner state of the backend object. Signed-off-by: Carlos López <carlos.lopez@suse.com>
1 parent e755cdb commit 2f44a69

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/devices/virtio-blk/src/stdio_executor.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,21 @@ impl<B: Backend> StdIoBackend<B> {
474474
}
475475
Ok(0)
476476
}
477+
478+
/// Obtains an immutable reference to the backing object.
479+
pub fn inner(&self) -> &B {
480+
&self.inner
481+
}
482+
483+
/// Obtains a mutable reference to the backing object.
484+
pub fn inner_mut(&mut self) -> &mut B {
485+
&mut self.inner
486+
}
487+
488+
/// Consumes the [`StdIoBackend`], returning its backing object.
489+
pub fn into_inner(self) -> B {
490+
self.inner
491+
}
477492
}
478493

479494
#[cfg(test)]

0 commit comments

Comments
 (0)