Replace the lock file contents with `metadata` while holding the lock.
(&mut self, metadata: impl AsRef<[u8]>)
| 162 | |
| 163 | /// Replace the lock file contents with `metadata` while holding the lock. |
| 164 | pub fn write_metadata(&mut self, metadata: impl AsRef<[u8]>) -> io::Result<()> { |
| 165 | self.lock.set_len(0)?; |
| 166 | self.lock.seek(SeekFrom::Start(0))?; |
| 167 | self.lock.write_all(metadata.as_ref())?; |
| 168 | self.lock.sync_data()?; |
| 169 | Ok(()) |
| 170 | } |
| 171 | |
| 172 | /// Release the lock and optionally remove the locked file. |
| 173 | /// |