pub struct FileBlockDevice { /* private fields */ }Expand description
A block device backed by a file on the host filesystem.
This is useful for working with disk images or loopback devices.
Implementations§
Source§impl FileBlockDevice
impl FileBlockDevice
Sourcepub fn create_with_block_size<P: AsRef<Path>>(
path: P,
size: u64,
block_size: u32,
) -> Result<Self>
pub fn create_with_block_size<P: AsRef<Path>>( path: P, size: u64, block_size: u32, ) -> Result<Self>
Create a new disk image file with custom block size.
Sourcepub fn open_with_block_size<P: AsRef<Path>>(
path: P,
block_size: u32,
) -> Result<Self>
pub fn open_with_block_size<P: AsRef<Path>>( path: P, block_size: u32, ) -> Result<Self>
Open an existing disk image file with custom block size.
Sourcepub fn open_read_only<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open_read_only<P: AsRef<Path>>(path: P) -> Result<Self>
Open an existing disk image file in read-only mode.
Trait Implementations§
Source§impl BlockDevice for FileBlockDevice
impl BlockDevice for FileBlockDevice
Source§fn read_blocks(&self, block_id: u64, buf: &mut [u8]) -> Result<u32>
fn read_blocks(&self, block_id: u64, buf: &mut [u8]) -> Result<u32>
Read blocks from the device. Read more
Source§fn write_blocks(&mut self, block_id: u64, buf: &[u8]) -> Result<u32>
fn write_blocks(&mut self, block_id: u64, buf: &[u8]) -> Result<u32>
Write blocks to the device. Read more
Source§fn block_size(&self) -> u32
fn block_size(&self) -> u32
Get the physical block size in bytes.
Source§fn block_count(&self) -> u64
fn block_count(&self) -> u64
Get the total number of blocks.
Auto Trait Implementations§
impl !Freeze for FileBlockDevice
impl RefUnwindSafe for FileBlockDevice
impl Send for FileBlockDevice
impl Sync for FileBlockDevice
impl Unpin for FileBlockDevice
impl UnsafeUnpin for FileBlockDevice
impl UnwindSafe for FileBlockDevice
Blanket Implementations§
Source§impl<T> BlockDeviceExt for Twhere
T: BlockDevice,
impl<T> BlockDeviceExt for Twhere
T: BlockDevice,
Source§fn total_size(&self) -> u64
fn total_size(&self) -> u64
Get the total size of the device in bytes.
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