pub trait Identifier:
Sized
+ Clone
+ PartialEq
+ Eq
+ Hash
+ Display
+ Serialize
+ for<'de> Deserialize<'de> {
// Required methods
fn parse<S: AsRef<str>>(s: S) -> Result<Self, IdentifierError>;
fn generate() -> Self;
fn as_str(&self) -> &str;
fn timestamp_ms(&self) -> Option<u64>;
}Expand description
Trait for identifier types
This trait defines the common interface for different identifier types (UUID, ULID).
It allows the EntityId type to be generic over the identifier implementation.
Required Methods§
Sourcefn parse<S: AsRef<str>>(s: S) -> Result<Self, IdentifierError>
fn parse<S: AsRef<str>>(s: S) -> Result<Self, IdentifierError>
Parse a string into an identifier
Sourcefn timestamp_ms(&self) -> Option<u64>
fn timestamp_ms(&self) -> Option<u64>
Get the timestamp in milliseconds (if applicable)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.