diff rust/hg-core/src/errors.rs @ 48464:abeae090ce67

rust: Add Vfs::write_atomic This method writes to a temporary file then renames in place Differential Revision: https://phab.mercurial-scm.org/D11836
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 29 Nov 2021 18:46:04 +0100
parents cf5f8da2244c
children 3f86ee422095
line wrap: on
line diff
--- a/rust/hg-core/src/errors.rs	Mon Mar 22 09:07:10 2021 +0100
+++ b/rust/hg-core/src/errors.rs	Mon Nov 29 18:46:04 2021 +0100
@@ -151,6 +151,8 @@
     /// Converts a `Result` with `std::io::Error` into one with `HgError`.
     fn when_reading_file(self, path: &std::path::Path) -> Result<T, HgError>;
 
+    fn when_writing_file(self, path: &std::path::Path) -> Result<T, HgError>;
+
     fn with_context(
         self,
         context: impl FnOnce() -> IoErrorContext,
@@ -162,6 +164,10 @@
         self.with_context(|| IoErrorContext::ReadingFile(path.to_owned()))
     }
 
+    fn when_writing_file(self, path: &std::path::Path) -> Result<T, HgError> {
+        self.with_context(|| IoErrorContext::WritingFile(path.to_owned()))
+    }
+
     fn with_context(
         self,
         context: impl FnOnce() -> IoErrorContext,