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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//! # Theater ID System
//!
//! This module provides the `TheaterId` type, which is used throughout the Theater system
//! to uniquely identify actors, resources, and other entities. The IDs are based on UUIDs
//! to ensure uniqueness across distributed environments.
//!
//! ## Example
//!
//! ```rust
//! use theater::id::TheaterId;
//! use std::str::FromStr;
//!
//! // Generate a new random ID
//! let id = TheaterId::generate();
//!
//! // Convert to string and back
//! let id_str = id.to_string();
//! let parsed_id = TheaterId::from_str(&id_str).unwrap();
//! assert_eq!(id, parsed_id);
//! ```
use ;
use fmt;
use FromStr;
use Uuid;
/// # TheaterId
///
/// A unique identifier for entities within the Theater system, including actors,
/// channels, and resources.
///
/// ## Purpose
///
/// TheaterId provides a type-safe way to identify and reference entities within the Theater
/// system. It helps prevent confusion between different types of IDs and enables strong
/// type checking at compile time.
///
/// ## Implementation Notes
///
/// Internally, TheaterId is implemented using UUIDs (Universally Unique Identifiers)
/// to ensure uniqueness across distributed systems without requiring central coordination.
;
/// Implementation of the FromStr trait for TheaterId.
///
/// This allows parsing a TheaterId from a string using the standard FromStr trait,
/// which enables using the `parse` method on strings and the `?` operator for error handling.
///
/// ## Example
///
/// ```rust
/// use theater::id::TheaterId;
/// use std::str::FromStr;
///
/// let id = TheaterId::from_str("550e8400-e29b-41d4-a716-446655440000").unwrap();
/// ```
/// Implementation of the Display trait for TheaterId.
///
/// This allows converting a TheaterId to a string using the standard Display trait,
/// which enables using it with string formatting macros like `format!`, `println!`, etc.
///
/// ## Example
///
/// ```rust
/// use theater::id::TheaterId;
///
/// let id = TheaterId::generate();
/// let id_string = format!("{}", id); // Converts to hyphenated UUID string
/// println!("Actor ID: {}", id); // Prints the ID in a readable format
/// ```