3 releases

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

#1611 in Rust patterns

Download history 136/week @ 2024-03-13 144/week @ 2024-03-20 156/week @ 2024-03-27 140/week @ 2024-04-03 99/week @ 2024-04-10 99/week @ 2024-04-17 107/week @ 2024-04-24 127/week @ 2024-05-01 139/week @ 2024-05-08 167/week @ 2024-05-15 158/week @ 2024-05-22 129/week @ 2024-05-29 124/week @ 2024-06-05 81/week @ 2024-06-12 133/week @ 2024-06-19 136/week @ 2024-06-26

495 downloads per month
Used in 19 crates (11 directly)

Apache-2.0 OR MIT

29KB
90 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.uuidgenerator.net, which provides a quick way generate new UUIDs that you can paste into your code.


lib.rs:

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

Dependencies

~1–17MB
~212K SLoC