This commit is contained in:
randogoth 2026-09-13 00:11:23 +03:00
commit 07ae2a3b20
109 changed files with 169 additions and 0 deletions

15
README.md Normal file
View file

@ -0,0 +1,15 @@
# td36
Time-delta identifiers: a timestamp is stored as the base36 encoding of its offset from a chosen epoch, so ids stay short, sortable and monotonically increasing.
```rust
use td36::{Td36Epoch, Td36Precision};
let epoch = Td36Epoch::new(1_700_000_000, Td36Precision::Seconds);
let id = epoch.encode(1_700_000_123).unwrap();
assert_eq!(epoch.decode_id(&id).unwrap(), 1_700_000_123);
```
`Td36Epoch::encode_epoch_marker` / `decode_epoch_marker` round-trip the epoch itself, so a stream of ids can carry the epoch it is relative to.
No dependencies. `cargo test` covers epoch round-tripping and the before-epoch guard.