pub struct SparseCache { /* private fields */ }Expand description
A tempfile-backed cache that tracks populated byte ranges.
Implementations§
Source§impl SparseCache
impl SparseCache
Sourcepub fn new(total_size: u64, spool_dir: &Path) -> Result<Self>
pub fn new(total_size: u64, spool_dir: &Path) -> Result<Self>
Create a new sparse cache for a file of the given total size.
Allocates an unlinked temp file in spool_dir (see crate::spool; the
cache holds every byte read so far, so it must not land in a tmpfs) and
sets its length so that sparse reads past the end don’t accidentally
return 0 bytes before the caller has fetched them.
Sourcepub fn missing_ranges(&self, offset: u64, size: u64) -> Vec<Range<u64>>
pub fn missing_ranges(&self, offset: u64, size: u64) -> Vec<Range<u64>>
Returns the byte ranges within [offset, offset+size) that are NOT yet populated.
The returned ranges are sorted and clipped to [0, total_size).
If the entire requested range is already populated, returns an empty Vec.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SparseCache
impl RefUnwindSafe for SparseCache
impl Send for SparseCache
impl Sync for SparseCache
impl Unpin for SparseCache
impl UnsafeUnpin for SparseCache
impl UnwindSafe for SparseCache
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