Crate fslock_arti_fork

Crate fslock_arti_fork 

Source
Expand description

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

NOTE: This is a fork of the fslock crate for use by Arti. We are forking temporarily because we need https://github.com/brunoczim/fslock/pull/15 in order to implement file deletion safely.

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.