simplelock 0.4.1

Simple abstractions for inter-process synchronization.
Documentation
//! SimpleLock is a set of utility functions and a simple [`Lock`] trait, which
//! can be used for inter-process synchronization. This differs from many of the
//! other "lock" packages in that it works cross-process using OS/FS/etc
//! mechanisms.
//!
//! We hope to expand and bundle a number of verified implementations with
//! it, but in the spirit of Rust's "only pay for what you use", they will
//! be gated behind feature flags or enclosed in separate packages.
//!
//! For example, you can use the [`FileLock`] implementation by adding
//! this to your Cargo.toml:
//!
//! ```toml
//! [dependencies]
//! simplelock = { version = "*", features = [ "file" ] }
//! ```
//!
//! Presently we have the following implementations available for use:
//!
//! * `fake` - Enables the [`FakeLock`] implementation (useful for testing only).
//! * `file` - Enables the [`FileLock`] implementation (most common and cross-platform).
//! * `sema` - Enables the [`SemaphoreLock`] implementation (minimal libc/nix only).
//!
//! Un-implemented mechanisms which may come later:
//!
//! * `smem` - Shared Memory.
//! * Simple distributed locks:
//!   * `http` - URL/web-hook based (i.e. [RFC 7232]).
//!   * `callback` - Customizable callback (i.e. redis dist-lock, etc).
//!
//! Please request others or hand-roll your own. You need not enable any features and implement
//! the [`Lock`] trait directly.
//!
//! # Examples:
//! ```rust
//! use simplelock::*;
//!
//! fn main() -> SimpleLockResult<()> {
//!     // Based on the "feature" enabled, this will create the default lock.
//!     // Will return a SimpleLockError on error, or if no lock type was enabled.
//!     let mut lock = default_lock("my_app_name")?;
//!
//!     // One utility function provided, simple critical-section locking.
//!     let result = lock_until_finished(
//!         &mut lock,
//!         || {
//!             /// Some critical code.
//! #       42
//!         })?;
//!
//!     // ... Do something with the result.
//! #   assert_eq!(42, result);
//! #   Ok(())
//! }
//! ```
//!
//! [`Lock`]: ./trait.Lock.html
//! [`FakeLock`]: ./struct.FakeLock.html
//! [`FileLock`]: ./struct.FileLock.html
//! [`SemaphoreLock`]: ./struct.SemaphoreLock.html
//! [RFC 7232]: https://tools.ietf.org/html/rfc7232

#![deny(missing_docs)]

#[macro_use]
extern crate cfg_if;

// Configure the lock during build.
mod builder;
pub use builder::*;

// SimpleLock error and result overrides.
mod error;
pub use error::*;

// Lock implementations
mod impls;
pub use impls::*;

// Lock type hierarchy
mod types;
pub use types::*;

// Ease-of-Use / Utility functionality.
mod util;
pub use util::*;