[][src]Struct lockfile::Lockfile

pub struct Lockfile { /* fields omitted */ }

A lockfile that cleans up after itself.

Inspired by TempPath in tempfile crate.

See module-level documentation for examples.

Methods

impl Lockfile[src]

pub fn create(path: impl AsRef<Path>) -> Result<Lockfile, Error>[src]

Create a lockfile at the given path.

This function will

  1. create parent directories, if necessary,
  2. create the lockfile.
  • If the directories already exist, it will skip creating them.
  • Any other error is returned.

Panics

Will panic if the path doesn't have a parent directory.

pub fn path(&self) -> &Path[src]

Get the path of the lockfile.

The impl of AsRef<Path> can also be used.

pub fn release(self) -> Result<(), Error>[src]

Close and remove the file, releasing the lock.

Use this instead of the destructor when you want to see if any errors occured when removing the file.

Trait Implementations

impl AsRef<Path> for Lockfile[src]

impl Debug for Lockfile[src]

impl Drop for Lockfile[src]

impl Read for Lockfile[src]

impl<'a> Read for &'a Lockfile[src]

impl Seek for Lockfile[src]

impl<'a> Seek for &'a Lockfile[src]

impl Write for Lockfile[src]

impl<'a> Write for &'a Lockfile[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.