Crates.io | fslock |
lib.rs | fslock |
version | 0.2.1 |
source | src |
created_at | 2020-01-01 05:47:08.522751 |
updated_at | 2021-12-20 19:12:35.80893 |
description | A library to use files as locks |
homepage | |
repository | https://github.com/brunoczim/fslock |
max_upload_size | |
id | 194064 |
size | 60,636 |
API to use files as a lock. Supports non-std crates by disabling feature
std
.
Currently, only one type is provided: [LockFile
]. It does not destroy the
file after closed and behaviour on locking different file handles owned by
the same process is different between Unix and Windows, unless you activate the
multilock
feature, which enables the open_excl
method that locks files per
file descriptor/handle on all platforms.
use fslock::LockFile;
fn main() -> Result<(), fslock::Error> {
let mut file = LockFile::open("mylock")?;
file.lock()?;
do_stuff();
file.unlock()?;
Ok(())
}