| Crates.io | wei-single |
| lib.rs | wei-single |
| version | 0.3.6 |
| created_at | 2024-01-13 07:49:58.480813+00 |
| updated_at | 2024-03-17 13:44:32.439331+00 |
| description | A rust library for single instance application. |
| homepage | |
| repository | https://github.com/WLBF/single-instance |
| max_upload_size | |
| id | 1098364 |
| size | 15,070 |
single-instance provides a single API to check if there are any other running instance.
On windows, init SingleInstance will create a mutex named by given &str then check error code by calling GetLastError. On linux init will bind abstract unix domain socket with given name . On macos, init will create or open a file which path is given &str, then call flock to apply an advisory lock on the open file.
[dependencies]
single-instance = "0.3"
extern crate single_instance;
use single_instance::SingleInstance;
fn main() {
{
let instance_a = SingleInstance::new("whatever").unwrap();
assert!(instance_a.is_single());
let instance_b = SingleInstance::new("whatever").unwrap();
assert!(!instance_b.is_single());
}
let instance_c = SingleInstance::new("whatever").unwrap();
assert!(instance_c.is_single());
}