pub struct StagingWriter { /* private fields */ }Expand description
Receives one blob into its own partial file, verifying it on
finish. Dropping it unfinished removes that file.
Implementations§
Source§impl StagingWriter
impl StagingWriter
Sourcepub fn write(&mut self, bytes: &[u8]) -> Result<()>
pub fn write(&mut self, bytes: &[u8]) -> Result<()>
Append the next piece. Fails with Error::TooLarge if the total would pass
the announced length.
Sourcepub fn finish(self) -> Result<PathBuf>
pub fn finish(self) -> Result<PathBuf>
Check the length and hash, then move the file to <hex> and return its path.
Anything other than the announced content is Error::ContentMismatch. If
another writer staged the same hash meanwhile, the rename replaces its file
with identical content; where that replacing fails (on Windows, while the file
is open without delete sharing), the staged file is kept and this one dropped.
The bytes are on disk before the rename, so a crash cannot leave a <hex> that
holds less than verified content. The rename itself may be lost to one; that
leaves only a .partial, which [clear_partials] removes, and the content is
asked for again.
Trait Implementations§
Source§impl Drop for StagingWriter
impl Drop for StagingWriter
Source§impl Write for StagingWriter
impl Write for StagingWriter
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)