| Crates.io | unique-uuid |
| lib.rs | unique-uuid |
| version | 0.1.1 |
| created_at | 2025-01-30 16:42:46.360229+00 |
| updated_at | 2025-01-30 16:45:03.069734+00 |
| description | A library to generate unique UUIDs. |
| homepage | |
| repository | https://github.com/BoyeGuillaume/rust-unique-uuid/tree/master |
| max_upload_size | |
| id | 1536597 |
| size | 10,881 |
A Rust library that provides stable, cross-platform unique identifiers for types using UUIDs.
Add this to your Cargo.toml:
[dependencies]
unique-uuid = "0.1.0"
use unique_uuid::UniqueTypeTag;
#[derive(UniqueTypeTag)]
struct MyType;
// Get the unique identifier for the type
let type_id = MyType::TYPE_TAG;
use unique_uuid_derive::unique_tag;
// Generate a unique identifier for a custom tag
let custom_id = unique_tag!("my-custom-tag");
The library generates and stores UUIDs in a types.toml file to ensure consistency across different compilations. Unlike std::any::TypeId, these identifiers remain stable across different builds and platforms.
Currently, structs with the same name (even in different modules or crates) will receive the same UUID. This is a known bug that will be addressed in future versions. Please ensure your struct names are unique across your entire project.
UUIDs are stored in a types.toml file with the following structure:
[unique_tags]
"custom-tag" = "uuid-value"
[unique_type_tags]
"MyType" = "uuid-value"
Contributions are welcome! Please feel free to submit a Pull Request.