Skip to content

Commit

Permalink
Add a README
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison committed Jan 9, 2019
1 parent 8a9fb98 commit 4366cb3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "type-uuid"
version = "0.1.0"
authors = ["Jacob Kiesel <kieseljake@gmail.com>", "David LeGare <dlegare.1001@gmail.com>"]
authors = ["David LeGare <dlegare.1001@gmail.com>", "Jacob Kiesel <kieseljake@gmail.com>"]
edition = "2018"

description = "Safe, stable IDs for Rust types"
readme = "./README.md"
documentation = "https://docs.rs/type-uuid"
repository = "https://github.com/randomPoison/type-uuid"
license = "Apache-2.0 OR MIT"
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
# type-uuid

This crate provides a way to specify a stable, unique identifier for Rust types.

## Assigning UUIDs to Types

This crate provides the [`TypeUuid`] trait, which defines a single const item
`UUID`. This value is a byte array containing the raw bytes of the UUID for the
type.

You will have to manually specify the UUID for any type implementing
[`TypeUuid`], but this crate provides a custom derive to make that easy to do:

```rust
use type_uuid::TypeUuid;

#[derive(TypeUuid)]
#[uuid = "d4adfc76-f5f4-40b0-8e28-8a51a12f5e46"]
struct MyType;
```

While the derive handles the tedious work of converting the UUID into a byte
array suitable for use with the [`TypeUuid`] trait, you'll still need to
generate a valid UUID in order to assign it to your type. To do so, we
recommend using https://www.uuidgenerator.net, which provides a quick way
generate new UUIDs that you can paste into your code.

[`TypeUuid`]: ./trait.TypeUuid.html

0 comments on commit 4366cb3

Please sign in to comment.