Struct oysterpack_uid::ulid::DomainULID
source · pub struct DomainULID { /* private fields */ }
Expand description
Represents a generic form of TypedULID<T>, i.e., it’s a ULID for the specified domain.
TypedULID<T> is a typed ULID. However, there are use cases where we want to erase the type and have a generic. An example use case is tagging events with UID(s) for different domains.
TypedULID<T> can be converted to a DomainULID automatically if the TypedULID type T implements HasDomain.
Example DomainULID generator function
fn new_request_id() -> DomainULID {
const DOMAIN: Domain = Domain("Request");
DomainULID::generate(&DOMAIN)
}
let request_id = new_request_id();
assert_eq!(request_id.domain(), "Request");
Implementations§
source§impl DomainULID
impl DomainULID
sourcepub fn generate(domain: &Domain) -> DomainULID
pub fn generate(domain: &Domain) -> DomainULID
Constructs a new ULID as DomainULID
sourcepub fn from_ulid(domain: &Domain, id: ULID) -> DomainULID
pub fn from_ulid(domain: &Domain, id: ULID) -> DomainULID
Associates the Domain to the ULID
Trait Implementations§
source§impl Clone for DomainULID
impl Clone for DomainULID
source§fn clone(&self) -> DomainULID
fn clone(&self) -> DomainULID
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DomainULID
impl Debug for DomainULID
source§impl<'de> Deserialize<'de> for DomainULID
impl<'de> Deserialize<'de> for DomainULID
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>,
Deserialize this value from the given Serde deserializer. Read more