Getting Started
This guide walks you through installing and setting up File-Based Semaphore.
Prerequisites
- Rust 1.70+ (for building from source)
- Unix/Windows system with filesystem access
Installation
From Source (Recommended)
bash
# Clone the repository
git clone https://github.com/tuulbelt/file-based-semaphore.git
cd file-based-semaphore
# Build release binary
cargo build --release
# Binary is at: target/release/sema
./target/release/sema --versionAs a Rust Library
Add to your Cargo.toml:
toml
[dependencies]
file-based-semaphore = { git = "https://github.com/tuulbelt/file-based-semaphore.git" }Quick Verification
bash
# Create a test lock
./target/release/sema try /tmp/test.lock
# Output: Lock acquired: /tmp/test.lock
# Check status
./target/release/sema status /tmp/test.lock
# Output: Lock status: LOCKED
# Release it
./target/release/sema release /tmp/test.lock
# Output: Lock released: /tmp/test.lockRunning Tests
bash
cargo test
# 85 tests should pass
cargo clippy -- -D warnings
# Zero warnings requiredProject Structure
file-based-semaphore/
├── Cargo.toml # Package manifest
├── src/
│ ├── lib.rs # Library implementation
│ └── main.rs # CLI implementation
├── tests/
│ └── integration.rs # Integration tests
├── examples/
│ ├── basic.rs # Basic usage example
│ └── concurrent.rs # Concurrent access example
├── README.md # Documentation
├── SPEC.md # Protocol specification
└── LICENSE # MIT licenseNext Steps
- CLI Usage - Learn the command-line interface
- Library Usage - Integrate into Rust projects
- Examples - See real-world patterns