pub struct TheaterId(Uuid);
Expand description
§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.
Tuple Fields§
§0: Uuid
Implementations§
Source§impl TheaterId
impl TheaterId
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generates a new random TheaterId.
§Purpose
This method creates a new, globally unique identifier that can be used to identify an actor, channel, or other entity in the Theater system.
§Returns
A new TheaterId instance with a random UUID.
§Example
use theater::id::TheaterId;
let id = TheaterId::generate();
§Implementation Notes
This method uses the UUID v4 algorithm, which generates IDs using random numbers. This ensures that IDs are unique across different machines without coordination.
Sourcepub fn parse(s: &str) -> Result<Self, Error>
pub fn parse(s: &str) -> Result<Self, Error>
Parses a TheaterId from a string.
§Parameters
s
- The string to parse
§Returns
Ok(TheaterId)
- The successfully parsed TheaterIdErr(uuid::Error)
- An error occurred during parsing
§Example
use theater::id::TheaterId;
let id_result = TheaterId::parse("550e8400-e29b-41d4-a716-446655440000");
assert!(id_result.is_ok());
let invalid_result = TheaterId::parse("not-a-valid-uuid");
assert!(invalid_result.is_err());
Sourcepub fn as_uuid(&self) -> &Uuid
pub fn as_uuid(&self) -> &Uuid
Gets the underlying UUID.
§Returns
A reference to the underlying Uuid.
§Example
use theater::id::TheaterId;
let id = TheaterId::generate();
let uuid = id.as_uuid();
§Purpose
This method allows access to the underlying UUID, which can be useful for interoperating with other systems or libraries that work with UUIDs directly.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TheaterId
impl<'de> Deserialize<'de> for TheaterId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for TheaterId
Implementation of the Display trait for TheaterId.
impl Display for TheaterId
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
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
Source§impl FromStr for TheaterId
Implementation of the FromStr trait for TheaterId.
impl FromStr for TheaterId
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
use theater::id::TheaterId;
use std::str::FromStr;
let id = TheaterId::from_str("550e8400-e29b-41d4-a716-446655440000").unwrap();
impl Eq for TheaterId
impl StructuralPartialEq for TheaterId
Auto Trait Implementations§
impl Freeze for TheaterId
impl RefUnwindSafe for TheaterId
impl Send for TheaterId
impl Sync for TheaterId
impl Unpin for TheaterId
impl UnwindSafe for TheaterId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more