Expand description

WARNING: v0.1.x is incompatible with v0.2.x onwards.

API to use files as a lock. Supports non-std crates by disabling feature std.

Types

Currently, only one type is provided: LockFile. It does not destroy the file after closed. Locks are per-handle and not by per-process in any platform. On Unix, however, under fork file descriptors might be duplicated sharing the same lock, but fork is usually unsafe in Rust.

Example

use fslock::LockFile;
fn main() -> Result<(), fslock::Error> {

    let mut file = LockFile::open("testfiles/mylock.lock")?;
    file.lock()?;
    do_stuff();
    file.unlock()?;

    Ok(())
}

Structs

A handle to a file that is lockable. Does not delete the file. On both Unix and Windows, the lock is held by an individual handle, and not by the whole process. On Unix, however, under fork file descriptors might be duplicated sharing the same lock, but fork is usually unsafe in Rust.

Borrowed allocation of an OS-native string.

Owned allocation of an OS-native string.

Enums

Either borrowed or owned allocation of an OS-native string.

Traits

Conversion of anything into an owned OS-native string. If allocation fails, an error shall be returned.

Conversion of anything to an either borrowed or owned OS-native string. If allocation fails, an error shall be returned.

Type Definitions

An IO error.