pub struct DestFile { /* private fields */ }Implementations§
Source§impl DestFile
impl DestFile
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open (or create) the destination for random-access writing without truncating: an existing partial file is exactly what we want to resume into.
Sourcepub fn preallocate(&self, size: u64) -> Result<()>
pub fn preallocate(&self, size: u64) -> Result<()>
Size the file up front. This turns “out of disk” into an error now rather than at 90%, and gives the filesystem a chance to lay the file out contiguously.
set_len creates a sparse file on every filesystem we target; it
reserves the size, not necessarily the blocks. We accept that: the
alternative (writing zeroes over the whole range) would double the I/O
for a 500 GB download.
Sourcepub fn write_at(&self, buf: &[u8], offset: u64) -> Result<()>
pub fn write_at(&self, buf: &[u8], offset: u64) -> Result<()>
Write every byte of buf at offset. Short writes are retried, so a
successful return means the whole buffer reached the kernel.
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
Sourcepub fn sync_data(&self) -> Result<()>
pub fn sync_data(&self) -> Result<()>
The durability barrier. See docs/CRASH_CONSISTENCY.md: this must
return before any of the bytes it covers may be recorded as complete.
sync_data rather than sync_all — we need the data and the block map
durable, not the mtime.
Sourcepub fn size(&self) -> Result<u64>
pub fn size(&self) -> Result<u64>
Named size rather than len because a file has no meaningful
is_empty counterpart and the pair would only mislead.
pub fn truncate(&self, size: u64) -> Result<()>
pub fn identity(&self) -> Result<FileIdentity>
pub fn path(&self) -> &Path
Sourcepub fn open_for_read(&self) -> Result<File>
pub fn open_for_read(&self) -> Result<File>
Reopen a fresh handle for hashing, so verification reads do not disturb the write handle.