ids/typeid

Module for generating TypeIDs.

Functions

pub fn decode(tid: String) -> Result(#(String, String), String)

Decode a TypeID into a tuple of #(prefix, uuid)

Usage

decode("user_01hz7c1d2bfkhb31sf10t9qtns") // Ok(#("user", "018fcec0-b44b-7ce2-b187-2f08349beab9"))
pub fn from_uuid(
  prefix prefix: String,
  uuid uuid: String,
) -> Result(String, String)

Generate a TypeID using the supplied prefix and UUID. Prefix may be an empty string.

Usage

from_uuid("user", "018fcec0-b44b-7ce2-b187-2f08349beab9") // Ok("user_01hz7c1d2bfkhb31sf10t9qtns")
pub fn generate(prefix prefix: String) -> Result(String, String)

Generate a TypeID using the supplied prefix. Prefix may be an empty string.

Usage

generate("user") // Ok("user_01hz7jxhgpfxh9m33bn41tcg9t")
generate("") // Ok("01hz7jv26zfnx9gpb0hvyc4pss")
Search Document