pub struct AtomicFileWriter { /* private fields */ }Expand description
原子文件写入器
使用临时文件 + 重命名模式实现原子写入。 在 Windows 上使用 os.replace(),在 NTFS 上是原子的。 在 Unix 上使用 rename(),在相同文件系统上是原子的。
Implementations§
Source§impl AtomicFileWriter
impl AtomicFileWriter
Sourcepub fn with_verify(self, verify: bool) -> Self
pub fn with_verify(self, verify: bool) -> Self
配置是否验证写入
Sourcepub fn write_atomic(&self, filepath: &Path, content: &str) -> Layer2Result<()>
pub fn write_atomic(&self, filepath: &Path, content: &str) -> Layer2Result<()>
Sourcepub fn safe_remove(&self, path: &Path) -> Layer2Result<()>
pub fn safe_remove(&self, path: &Path) -> Layer2Result<()>
安全删除文件
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AtomicFileWriter
impl RefUnwindSafe for AtomicFileWriter
impl Send for AtomicFileWriter
impl Sync for AtomicFileWriter
impl Unpin for AtomicFileWriter
impl UnsafeUnpin for AtomicFileWriter
impl UnwindSafe for AtomicFileWriter
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