pub struct Id<T>where
T: IdMarker,{ /* private fields */ }Expand description
Generic UUID-based identifier with phantom type safety.
Provides compile-time type differentiation between different ID types (e.g., SessionId vs StreamId) while sharing a single implementation.
§Type Safety
The phantom type parameter T ensures that different ID types cannot
be accidentally mixed:
ⓘ
let session_id: SessionId = SessionId::new();
let stream_id: StreamId = session_id; // Compile error!§Zero-Cost Abstraction
PhantomData<T> is a zero-sized type, so Id<T> has the same memory
layout as a plain Uuid.
§Examples
let session_id = SessionId::new();
let stream_id = StreamId::new();
// Type-safe: cannot compare different ID types
// session_id == stream_id // Would not compileImplementations§
Trait Implementations§
impl<T> Copy for Id<T>
impl<T> Eq for Id<T>
impl<T> StructuralPartialEq for Id<T>where
T: IdMarker,
Auto Trait Implementations§
impl<T> Freeze for Id<T>
impl<T> RefUnwindSafe for Id<T>where
T: RefUnwindSafe,
impl<T> Send for Id<T>
impl<T> Sync for Id<T>
impl<T> Unpin for Id<T>where
T: Unpin,
impl<T> UnwindSafe for Id<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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