[][src]Crate fd_lock

Advisory cross-platform file locks using file descriptors.

Note that advisory lock compliance is opt-in, and can freely be ignored by other parties. This means this crate should not be relied on for security, but solely used to coordinate file access.

Example

use fd_lock::FdLock;

// Lock a file and write to it.
let mut f = FdLock::new(tempfile()?);
f.try_lock()?.write_all(b"chashu cat")?;

// Locks can also be held for extended durations.
let mut f = f.try_lock()?;
f.write_all(b"nori cat")?;
f.write_all(b"bird!")?;

Structs

Error

A specialized Error type.

FdLock

A file descriptor lock.

FdLockGuard

A guard that unlocks the file descriptor when it goes out of scope.

Enums

ErrorKind

Error categories.