Crate fslock

Source
Expand description

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§

LockFile
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.
OsStr
Borrowed allocation of an OS-native string.
OsString
Owned allocation of an OS-native string.

Enums§

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

Traits§

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

Type Aliases§

Error
An IO error.