1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
// License: see LICENSE file at root directory of `master` branch

//! # Namaste
//!
//! ## Project
//!
//! - Repository: <https://bitbucket.org/haibison/namaste-rs>
//! - License: Nice License 1.0.0 _(see LICENSE file at root directory of `master` branch)_
//! - _This project follows [Semantic Versioning 2.0.0]_
//!
//! ## Features
//!
//! - Handling locks amongst processes via TCP.
//!
//! ## Design
//!
//! ### Identifier
//!
//! An identifier - ID - is a 64-byte array, which matches an [SHA3-512][wiki:SHA3] hash.
//!
//! [`Namaste`][::Namaste] can be used to lock an ID.
//!
//! - On Linux, it uses abstract sockets (see `unix(7)`).
//! - On other Unix systems, it uses file locks.
//!
//! ## Frequently Answered Questions
//!
//! ### Why not Unix Domain Socket?
//!
//! UDS has a good design, but its implementation has some **serious** flaws:
//!
//! - Already-bound file path _can be deleted_. Any new binding to that path will _silently take control_ of current one.
//!
//! ## Other notes
//!
//! To generate an ID, you can get help from [Dia-Hammer][crate:dia-hammer]:
//!
//! ```shell
//! $ hammer sha3-512 --limit=65536 --format=hex-array -- /dev/urandom
//! ```
//!
//! To generate a handshake ID, you can use [`tiny-keccak`][crate:tiny-keccak].
//!
//! [Semantic Versioning 2.0.0]: https://semver.org/spec/v2.0.0.html
//!
//! [wiki:SHA3]: https://en.wikipedia.org/wiki/SHA-3
//!
//! [::Namaste]: struct.Namaste.html
//!
//! [crate:dia-hammer]: https://bitbucket.org/haibison/hammer
//! [crate:libc]: https://crates.io/crates/libc
//! [crate:tiny-keccak]: https://crates.io/crates/tiny-keccak

#[macro_use]
#[allow(unused_macros)]
mod __;
#[cfg(unix)]
mod namaste;
#[cfg(unix)]
mod root;

#[cfg(unix)]
pub use crate::namaste::*;
#[cfg(unix)]
pub use root::*;

pub mod version_info;

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

macro_rules! code_name  { () => { "namaste" }}
macro_rules! version    { () => { "0.15.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) = (2019, 8, 9);

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

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

/// # 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"));
}