lode/types/uuid

Ecto.UUID — UUIDs as canonical lowercase hex strings (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

cast/load/dump are pure (validate + canonicalize). Generation uses a tiny Erlang FFI over crypto:strong_rand_bytes/1. v7 (time-ordered) generation is deliberately deferred.

Decoding also accepts the raw 16-byte binary form, because that is how pgo hands uuid columns back through pog (lode-2e5): the adapter’s dynamic row decoder surfaces those bytes as VBinary — or, when they happen to be valid UTF-8, as a short VString, so a 16-byte string is recovered as bytes too. A canonical uuid string is 36 characters, so the two string forms cannot collide.

Values

pub fn canonicalize(s: String) -> Result(String, Nil)

Validate the textual form and return it lowercased, or Error if malformed.

pub fn from_binary(bits: BitArray) -> Result(String, Nil)

The raw 16-byte binary form (how Postgres drivers hand uuids back) as a canonical lowercase string. Any other width is Error.

pub fn generate_v4() -> String

Generate a random v4 UUID as a canonical lowercase string.

pub fn uuid() -> type_.LodeType(String)

The UUID type for schema field declarations.

Search Document