namaste 0.19.0

Simple locks between processes
Documentation
// License: see LICENSE file at root directory of main branch

//! # Namaste
//!
//! ## Project
//!
//! - Repository: <https://bitbucket.org/haibison/namaste-rs>
//! - License: Nice License 1.0.1 _(see LICENSE file at root directory of main branch)_
//! - _This project follows [Semantic Versioning 2.0.0]_
//!
//! ## Features
//!
//! Handling locks amongst processes.
//!
//! ## Usage
//!
//! An identifier is a non-empty byte array. Up to 64 bytes are supported. So, for example, you can use SHA3-512 hashes as IDs.
//!
//! You can call [`make()`][fn:make] or [`make_wait()`][fn:make_wait] to lock your IDs. When done, simply drop them via `drop()`.
//!
//! ## Notes
//!
//! | System  | Requirements | Implementation details
//! | ------- | ------------ | ----------------------
//! | Linux   | Nightly Rust | Abstract sockets (see `unix(7)`)
//! | Windows |              | [Mutex objects][win:mutex-objects]
//!
//! Other systems are not supported.
//!
//! [Semantic Versioning 2.0.0]: https://semver.org/spec/v2.0.0.html
//! [win:mutex-objects]: https://docs.microsoft.com/en-us/windows/win32/sync/mutex-objects
//!
//! [fn:make]: fn.make.html
//! [fn:make_wait]: fn.make_wait.html

// TODO: remove these when related APIs are stabilized
#![cfg_attr(any(target_os = "linux", target_os = "l4re", target_os = "android"), feature(unix_socket_abstract))]

// ╔═════════════════╗
// ║   IDENTIFIERS   ║
// ╚═════════════════╝

macro_rules! code_name  { () => { "namaste" }}
macro_rules! version    { () => { "0.19.0" }}

/// # Crate name
pub const NAME: &str = "Namaste";

/// # Crate code name
pub const CODE_NAME: &str = code_name!();

/// # ID of this crate
pub const ID: &str = concat!(
    "b1b4db58-59414682-a029819c-84b9a4e1-170e0050-92722253-fae9dfd6-b652a960-",
    "e553656c-6b625519-392bb87b-c23a6af3-c498c567-ff5c242f-606d2694-9113a891",
);

/// # Crate version
pub const VERSION: &str = version!();

/// # Crate release date (year/month/day)
pub const RELEASE_DATE: (u16, u8, u8) = (2022, 9, 6);

/// # Tag, which can be used for logging...
pub const TAG: &str = concat!(code_name!(), "::b1b4db58::", version!());

// ╔════════════════════╗
// ║   IMPLEMENTATION   ║
// ╚════════════════════╝

/// # Wrapper for format!(), which prefixes your optional message with: crate::TAG, module_path!(), line!()
macro_rules! __ {
    ($($arg: tt)+) => {
        format!("[{tag}][{module_path}-{line}] {msg}", tag=crate::TAG, module_path=module_path!(), line=line!(), msg=format!($($arg)+))
    };
    () => {
        format!("[{tag}][{module_path}-{line}] (internal error)", tag=crate::TAG, module_path=module_path!(), line=line!())
    };
}

#[cfg(any(target_os = "linux", target_os = "l4re", target_os = "android"))]
mod linux;
#[cfg(any(target_os = "linux", target_os = "l4re", target_os = "android", target_os = "windows"))]
mod root;
#[cfg(windows)]
mod windows;

#[cfg(any(target_os = "linux", target_os = "l4re", target_os = "android"))]
pub use self::linux::*;

#[cfg(any(target_os = "linux", target_os = "l4re", target_os = "android", target_os = "windows"))]
pub use self::root::*;

#[cfg(windows)]
pub use self::windows::*;

pub mod version_info;

/// # Result type used in this crate
pub type Result<T> = std::io::Result<T>;

#[test]
fn test_crate_version() {
    assert_eq!(VERSION, env!("CARGO_PKG_VERSION"));
}