pub struct BlockCache<D> { /* private fields */ }
Expand description
A caching layer for block devices
Caches a single block.
Implementations§
Source§impl<D> BlockCache<D>where
D: BlockDevice,
impl<D> BlockCache<D>where
D: BlockDevice,
Sourcepub fn new(block_device: D) -> BlockCache<D>
pub fn new(block_device: D) -> BlockCache<D>
Create a new block cache
Sourcepub fn read(&mut self, block_idx: BlockIdx) -> Result<&Block, D::Error>
pub fn read(&mut self, block_idx: BlockIdx) -> Result<&Block, D::Error>
Read a block, and return a reference to it.
Sourcepub fn read_mut(&mut self, block_idx: BlockIdx) -> Result<&mut Block, D::Error>
pub fn read_mut(&mut self, block_idx: BlockIdx) -> Result<&mut Block, D::Error>
Read a block, and return a reference to it.
Sourcepub fn write_back(&mut self) -> Result<(), D::Error>
pub fn write_back(&mut self) -> Result<(), D::Error>
Write back a block you read with Self::read_mut
and then modified.
Sourcepub fn write_back_with_duplicate(
&mut self,
duplicate: BlockIdx,
) -> Result<(), D::Error>
pub fn write_back_with_duplicate( &mut self, duplicate: BlockIdx, ) -> Result<(), D::Error>
Write back a block you read with Self::read_mut
and then modified, but to two locations.
This is useful for updating two File Allocation Tables.
Sourcepub fn block_device(&mut self) -> &mut D
pub fn block_device(&mut self) -> &mut D
Access the block device
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for BlockCache<D>where
D: Freeze,
impl<D> RefUnwindSafe for BlockCache<D>where
D: RefUnwindSafe,
impl<D> Send for BlockCache<D>where
D: Send,
impl<D> Sync for BlockCache<D>where
D: Sync,
impl<D> Unpin for BlockCache<D>where
D: Unpin,
impl<D> UnwindSafe for BlockCache<D>where
D: 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