funclock_fs

Crates.iofunclock_fs
lib.rsfunclock_fs
version0.1.1
sourcesrc
created_at2024-07-27 11:37:33.852089
updated_at2024-07-27 11:42:13.616578
descriptionA simple file system locker to block functions and set session based logic.
homepage
repository
max_upload_size
id1317202
size5,802
Advait Pandharpurkar (lordofwizard)

documentation

README

funclock_fs

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.

Features

  • Create lock files with a specified session name.
  • Check if a lock file exists.
  • Create a lock file if it doesn't exist.
  • Remove a lock file when no longer needed.

Installation

Add funclock_fs to your Cargo.toml file:

[dependencies]
funclock_fs = "0.1"  # Replace with the latest version

Usage

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();
}

API Documentation

The API documentation for funclock_fs is available on docs.rs. You can also view the documentation by running:

cargo doc --open

Contributing

Contributions are welcome! Please fork the repository on GitHub and submit a pull request with your changes.

License

funclock_fs is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgements

  • The crate is inspired by common practices in file locking mechanisms.
  • Special thanks to the Rust community for their valuable contributions and support.
Commit count: 0

cargo fmt