Skip to content

Commit

Permalink
A little more doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
wyhaines committed Apr 15, 2022
1 parent 7a21b1c commit 812ee5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ The other options is to truncate 2 bytes off of the seconds, storing 6 bytes of

The current implementation chose option #2, as it is less work to generate a UUID if math is not involved.

The byte structure of the CSUUID is:

```
+-------------+-----------------+------------+
| nanoseconds | seconds | identifier |
| 0..3 | 4..10 | 11..15 |
+-------------+-----------------+------------+
```

The representational structure of the CSUUID, however, is itself sortable, as are the objects themselves.

```plain
.00.0e.d9.eb.-.7e.05.-.08.ae.-.f2.9c.-.df.18.10.1c.4a.dc.
^ seconds ^ nanoseconds ^identifier/entropy^
```


## Installation

1. Add the dependency to your `shard.yml`:
Expand Down
7 changes: 7 additions & 0 deletions src/csuuid.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ require "crystal/spin_lock"
# +-------------+-----------------+------------+
# ```
#
# The representational structure of the CSUUID, however, is itself sortable, as are the objects themselves.
#
# ```plain
# .00.0e.d9.eb.-.7e.05.-.08.ae.-.f2.9c.-.df.18.10.1c.4a.dc.
# ^ seconds ^ nanoseconds ^identifier/entropy^
# ```
#
struct CSUUID
# CSUUID will work with any source of entropy that inherits from Random.
# It defaults to `Random::ISAAC`.
Expand Down

0 comments on commit 812ee5e

Please sign in to comment.