A simple cross-process locking API

Overview

Developed with ❤️ by Tabnine

Proc-lock

A simple cross-process locking API.

Quick Start

Installation

In your Cargo.toml file, add:

[dependencies]
proc-lock = "*"

Using the API directly

use proc_lock::{lock, LockPath};

fn main() {
    let lock_path = LockPath::Tmp("my_lock.lock");
    let guard = lock(&lock_path).unwrap();
    // Until `guard` is dropped, this code section is atomic across multiple processes.
    // ...
    drop(guard);
}

Using macros

use proc_lock::proclock;

fn main() {
 // A lock will be acquired at the beginning of this function, and will be released at the end.
 a_sensitive_function();
}

#[proc_lock(name = "my_lock.lock")]
fn a_sensitive_function() {}

Current status

⚠️ This crate is in its early stages, breaking changes are expected in upcoming releases.

Changelog

  • 0.4.0 - Change interdependencies to local for better development process
  • 0.3.3 - Minor docs changes
  • 0.3.2 - Fix macro compilation
  • 0.3.1 - Change docs
  • 0.3.0 - [breaking changes] Rename crate to proc-lock, and the macro to proc_lock
  • 0.2.1 - Add a notice about renaming the crate
  • 0.2.0 - [breaking changes] Stop supporting non-blocking macro api

Contribution

Please refer to our project, as well as open issues.

Also feel free to discuss and open PRs regardless :)

Developement

  1. Run tests:
cargo test
  1. Run clippy
cargo clippy --all --all-targets --all-features -- --no-deps -D clippy::pedantic
You might also like...
A cross-platform application for custom presence on Discord.
A cross-platform application for custom presence on Discord.

Discord Presence ⚠️ macOS is NOT supported. This is due the package for setting the presence being broken on mac. It may work for some people (only wh

A cross platform forensic parser written in Rust!

artemis artemis is a powerful command line digital forensic and incident response (DFIR) tool that collects forensic data from Windows and macOS endpo

Notion Offical API client library for rust

Notion API client library for rust.

Rust lib for Scaleway API

Notes This Scaleway API Crate is created and maintained by Qovery and used in production in the Qovery Engine. This project relies on OpenAPI Generato

mdzk is a plain text Zettelkasten system that is based on the mdBook API.

mdzk A lovingly designed system and static publishing tool for your plain text Zettelkasten mdzk is a plain text Zettelkasten system that is based on

The official rust implementation of the SpamProtectionBot API
The official rust implementation of the SpamProtectionBot API

SpamProtection-rs Table of contents About Supported Rust version Features How to use Credits License About SpamProtection-Rust is a Rust wrapper for I

An asynchronous Rust client library for the Hashicorp Vault API

vaultrs An asynchronous Rust client library for the Hashicorp Vault API The following features are currently supported: Auth AppRole JWT/OIDC Token Us

Rust bindings for the KING OF TIME API

Rust bindings for the KING OF TIME API Example Prints if you are at work or not at work. $ cargo run --example tc -- status Record the time you start

A Rust API for D-Bus communication.

zbus A Rust API for D-Bus communication. The goal is to provide a safe and simple high- and low-level API akin to GDBus, that doesn't depend on C libr

Comments
  • Refine `LockGuard` docs

    Refine `LockGuard` docs

    The docs on LockGuard states that its similar to MutexGuard's behacior, and this is a bit misleading, because MutexGuard holds the actual data such that it cant be accessed without the guard. LockGuard is different from MutexGuard in that sense - there's no limitation on any data access enforced by this guard. They are similar only in the aspect of Drop, in which they both release the lock.

    documentation good first issue 
    opened by yonip23 0
  • Put the macro crate behind a compilation feature

    Put the macro crate behind a compilation feature

    The idea is to let users use this crate like so:

    proc-lock = { version = "x", features = ["macros"] }
    

    and the macro will be compiled only if the "macros" feature is enabled.

    enhancement good first issue 
    opened by yonip23 0
  • Not clear if this project is 🚀🚀ultra fast🚀🚀 and if its 🚀🚀memory safe🚀🚀

    Not clear if this project is 🚀🚀ultra fast🚀🚀 and if its 🚀🚀memory safe🚀🚀

    Project seems cool, but its unclear if this project is 🚀ultra🚀fast🚀 without reading the code

    Also, reading the code im not sure if anything here is 🚀memory🚀safe🚀

    Consider adding 🚀🚀🚀 to your readme

    discussion 
    opened by itty-todder 2
Owner
Tabnine
Tabnine | Code Faster with AI Code Completions
Tabnine
secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process.

secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process. More specifically, the crate disables core dumps and tries to disable tracing on unix-like OSes.

null 3 Dec 19, 2022
This is a simple Telegram bot with interface to Firefly III to process and store simple transactions.

Firefly Telegram Bot Fireflies are free, so beautiful. (Les lucioles sont libres, donc belles.) ― Charles de Leusse, Les Contes de la nuit This is a s

null 13 Dec 14, 2022
Modrinth API is a simple library for using, you guessed it, the Modrinth API in Rust projects

Modrinth API is a simple library for using, you guessed it, the Modrinth API in Rust projects. It uses reqwest as its HTTP(S) client and deserialises responses to typed structs using serde.

null 21 Jan 1, 2023
A small monitoring process that checks if kstars is active, if not it sends a request to notify a user via telegram that it crashed

Astro monitor A small monitoring process that checks if kstars is active, if not it sends a request to notify a user via telegram that it crashed Inst

Mattia Procopio 2 Jan 10, 2022
API wrapper for the tankerkönig api

tankerkoenig-rs API wrapper for the tankerkoenig-api written in rust. Gives you ready deserialized structs and a easy to use and strictly typed api. I

Jonathan 2 Feb 27, 2022
A repository full of manually generated hand curated JSON files, which contain the API Types that the Discord API returns.

Discord API Types A repository full of manually generated hand curated JSON files, which contain the API Types that the Discord API returns. Also did

Unofficial Discord Documentation 1 Sep 16, 2022
A simple Pokedex API

A simple Pokedex API

Chris Tsang 1 Nov 14, 2021
A simple, yet feature-filled wrapper around the coqui-stt C API

A simple, yet feature-filled wrapper around the coqui-stt C API

0/0 56 Jan 3, 2023
A simple, fast and fully-typed JSPaste API wrapper for Rust

rspaste A simple, fast and fully-typed JSPaste API wrapper for Rust. aidak.tk » Installation Put the desired version of the crate into the dependencie

Aidak 2 May 17, 2022
Cross-platform GUI written in Rust using ADB to debloat non-rooted android devices

Cross-platform GUI written in Rust using ADB to debloat non-rooted android devices. Improve your privacy, the security and battery life of your device.

w1nst0n 6.8k Jan 2, 2023