# ash-time
Distributed time primitives for Rust. `ash-time` is a toolkit for reasoning about
order and causality across nodes — answering "did A happen before B?" without a
central coordinator.
```
Node A ── stamp(write) → ts=(103ms, 0) ──────────────────────────▶
│ message carries ts
▼
Node B ── recv(ts) → ts=(103ms, 1) ── stamp(read) → ts=(103ms, 2) ──▶
(103ms, 0) < (103ms, 2): the read is provably after the write.
```
## Algorithms
### Hybrid Logical Clock (`ash_time::hlc`)
Tracks causality while staying anchored to wall time. The clock ticks with the
system clock when it can, and falls back to a logical counter to break ties within
the same nanosecond.
```rust
use ash_time::HlcClock;
let clock = HlcClock::new();
// stamp an outgoing message
let send_ts = clock.now().unwrap();
// advance on an incoming message — recv_ts is provably after send_ts
let recv_ts = clock.recv(send_ts).unwrap();
assert!(send_ts.happened_before(recv_ts));
```
See the [crate docs](https://docs.rs/ash-time) for the full API.
## Installation
```sh
cargo add ash-time
```
## License
Licensed under the [Apache License, Version 2.0](LICENSE).