1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! A type-safe UUID-based tagging system for Rust.
//!
//! This crate provides a way to associate unique, stable identifiers with types
//! across different platforms and compilation units. Unlike [`std::any::TypeId`],
//! these identifiers remain stable across different compilations and platforms.
//!
//! # Features
//!
//! - Cross-platform stable type identification
//! - Serialization support via the `serde` feature
//! - Type-safe wrapper around UUIDs
//!
//! # Example
//!
//! ```rust
//! use unique_uuid::{UniqueTypeTag, UniqueTag};
//!
//! #[derive(UniqueTypeTag)]
//! struct MyType;
//!
//! let tag = MyType::TYPE_TAG;
//! ```
pub extern crate uuid;
pub use *;
use Uuid;
/// A type-safe wrapper around [`uuid::Uuid`] for storing unique type identifiers.
///
/// `UniqueTag` provides a way to associate stable, unique identifiers with types.
/// It uses a UUID internally to ensure global uniqueness while maintaining
/// type safety through its wrapper type.
///
/// # Representation
///
/// The struct is marked with `#[repr(transparent)]` to ensure it has the same
/// memory layout as the underlying UUID, making it efficient to store and pass.
///
/// # Serialization
///
/// When the `serde` feature is enabled, this type implements `Serialize` and
/// `Deserialize` for compatibility with serde-based serialization formats.
;
/// A trait for types that have an associated unique identifier.
///
/// This trait provides a stable way to identify types across different
/// compilations and platforms. Unlike [`std::any::TypeId`], the identifiers
/// generated by this trait remain constant across different builds and platforms.
///
/// # Examples
///
/// ```rust
/// use unique_uuid::{UniqueTypeTag, UniqueTag};
///
/// #[derive(UniqueTypeTag)]
/// struct MyStruct;
///
/// assert_eq!(MyStruct::TYPE_TAG, MyStruct.type_id());
/// ```
///
/// # Deriving
///
/// This trait can be automatically derived using the `#[derive(UniqueTypeTag)]`
/// macro provided by this crate.