pub struct Transaction { /* private fields */ }Expand description
Several writes staged beside their destinations, renamed over them in order on commit; a staged file that is never committed is removed when the transaction drops.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn stage(&mut self, path: &Path, bytes: &[u8]) -> Result<()>
pub fn stage(&mut self, path: &Path, bytes: &[u8]) -> Result<()>
Stage bytes for path: written whole and synced beside the
destination, which holds what it held until commit.
§Errors
Any I/O failure from creating or writing the staged file; the destination is untouched.
Sourcepub fn commit(self) -> Result<Vec<PathBuf>, Interrupted>
pub fn commit(self) -> Result<Vec<PathBuf>, Interrupted>
Rename every staged file over its destination, in staging order.
§Errors
The first rename that fails stops the commit; the result names every destination renamed before it. The remaining staged files are removed, so no destination is ever half-written.
Sourcepub fn commit_stopping_at(
self,
stop: Option<&Path>,
) -> Result<Vec<PathBuf>, Interrupted>
pub fn commit_stopping_at( self, stop: Option<&Path>, ) -> Result<Vec<PathBuf>, Interrupted>
Self::commit, stopped on purpose before the rename over
stop, as if that rename had failed. This is the one seam the
interruption proof needs: a rename cannot be made to fail from
outside without a read failing first, and the proof is about what
the tree holds after a commit that stopped part way.
§Errors
As Self::commit, plus the injected stop.