| Crates.io | funclock_fs |
| lib.rs | funclock_fs |
| version | 0.1.1 |
| created_at | 2024-07-27 11:37:33.852089+00 |
| updated_at | 2024-07-27 11:42:13.616578+00 |
| description | A simple file system locker to block functions and set session based logic. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1317202 |
| size | 5,802 |
funclock_fs is a Rust crate designed to manage lock files for session-based locking. It provides a simple way to prevent concurrent access to resources by creating and managing lock files in the /tmp directory.
Add funclock_fs to your Cargo.toml file:
[dependencies]
funclock_fs = "0.1" # Replace with the latest version
Here’s a quick example of how to use funclock_fs:
use funclock_fs::LockFile;
fn main() {
// Create a new LockFile instance with the session name "my_session"
let lockfile = LockFile::new("my_session");
// Check if the lock file exists
if lockfile.is_locked() {
println!("Lock file exists.");
} else {
println!("Lock file does not exist.");
}
// Create the lock file
lockfile.lock();
// Release the lock file
lockfile.release();
}
The API documentation for funclock_fs is available on docs.rs. You can also view the documentation by running:
cargo doc --open
Contributions are welcome! Please fork the repository on GitHub and submit a pull request with your changes.
funclock_fs is licensed under the MIT License. See the LICENSE file for more details.