Expand description
This crate provides procedural macros for generating unique UUIDs associated with tags and types. It offers two main functionalities:
unique_tag: A procedural macro that generates a unique UUID for a given string tagUniqueTypeTag: A derive macro that automatically generates a unique UUID for a type
The generated UUIDs are persisted in a TOML file (types.toml by default) to ensure
consistency across multiple compilations and crate boundaries.
§Features
- Persistent UUID generation and storage
- Consistent UUID mapping for types and tags
- Thread-safe file handling
- TOML-based storage format
§Examples
use unique_uuid_derive::{unique_tag, UniqueTypeTag};
// Using unique_tag macro
let my_tag = unique_tag!("my_custom_tag");
// Using UniqueTypeTag derive macro
#[derive(UniqueTypeTag)]
struct MyStruct;§File Structure
The crate maintains a TOML file with the following structure:
[unique_tags]
"tag_name" = "uuid"
[unique_type_tags]
"type_name" = "uuid"§Implementation Details
- UUIDs are generated using UUID v4 (random)
- File operations are performed with proper error handling
- The system supports both string tags and type tags
§Safety
This crate performs file I/O operations during compilation, which may fail if:
- The process lacks file system permissions
- The TOML file becomes corrupted
- Concurrent compilation attempts cause file access conflicts
Macros§
- unique_
tag - A procedural macro that generates a unique UUID for a given string tag. The generated UUID is persisted in a TOML file to ensure consistency across multiple compilations and crate boundaries.
Derive Macros§
- Unique
Type Tag - A derive macro that automatically generates a unique UUID for a type. The generated UUID is associated with the type name and persisted in a TOML file to ensure consistency across multiple compilations and crate boundaries.