3 releases

0.1.2 Dec 2, 2019
0.1.1 Jan 17, 2019
0.1.0 Jan 9, 2019

#90 in #byte-array

Download history 135/week @ 2024-06-03 86/week @ 2024-06-10 97/week @ 2024-06-17 173/week @ 2024-06-24 57/week @ 2024-07-01 122/week @ 2024-07-08 153/week @ 2024-07-15 72/week @ 2024-07-22 217/week @ 2024-07-29 196/week @ 2024-08-05 204/week @ 2024-08-12 105/week @ 2024-08-19 213/week @ 2024-08-26 197/week @ 2024-09-02 128/week @ 2024-09-09 132/week @ 2024-09-16

680 downloads per month
Used in 20 crates (via type-uuid)

Apache-2.0 OR MIT

5KB
79 lines

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:

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.uuidtools.com/generate/v4, which provides a quick way generate new UUIDs that you can paste into your code.

Dependencies

~1.5MB
~40K SLoC