pub struct Mapfile { /* private fields */ }Expand description
Write-through mapfile. Every record() persists to disk immediately
so a crash during rip loses at most one block.
Implementations§
Source§impl Mapfile
impl Mapfile
Sourcepub fn create(path: &Path, total_size: u64, version: &str) -> Result<Self>
pub fn create(path: &Path, total_size: u64, version: &str) -> Result<Self>
Create a new mapfile with one NonTried region covering the whole disc.
Writes to disk immediately so a resume can pick up even if the caller
never records anything.
Sourcepub fn open_or_create(
path: &Path,
total_size: u64,
version: &str,
) -> Result<Self>
pub fn open_or_create( path: &Path, total_size: u64, version: &str, ) -> Result<Self>
Load if the file exists, otherwise create a fresh mapfile.
Sourcepub fn record(
&mut self,
pos: u64,
size: u64,
status: SectorStatus,
) -> Result<()>
pub fn record( &mut self, pos: u64, size: u64, status: SectorStatus, ) -> Result<()>
Mark a byte range as having the given status. Splits any overlapping existing entries, merges with adjacent same-status entries, and flushes to disk.
pub fn entries(&self) -> &[MapEntry]
pub fn total_size(&self) -> u64
Sourcepub fn next_with(&self, from: u64, status: SectorStatus) -> Option<(u64, u64)>
pub fn next_with(&self, from: u64, status: SectorStatus) -> Option<(u64, u64)>
First range with a given status starting at or after from.
Sourcepub fn ranges_with(&self, statuses: &[SectorStatus]) -> Vec<(u64, u64)>
pub fn ranges_with(&self, statuses: &[SectorStatus]) -> Vec<(u64, u64)>
All ranges matching one of the given statuses, in position order.
pub fn stats(&self) -> MapStats
Auto Trait Implementations§
impl Freeze for Mapfile
impl RefUnwindSafe for Mapfile
impl Send for Mapfile
impl Sync for Mapfile
impl Unpin for Mapfile
impl UnsafeUnpin for Mapfile
impl UnwindSafe for Mapfile
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