Skip to main content

Crate friendly_id

Crate friendly_id 

Source
Expand description

§friendly_id

Converts UUIDs to URL-friendly Base62 IDs and back.

The Base62 alphabet used is 0-9A-Za-z, producing a compact string of up to 22 characters for any UUID.

§Examples

// Encode a UUID to a friendly ID
let uuid = uuid::Uuid::parse_str("c3587ec5-0976-497f-8374-61e0c2ea3da5").unwrap();
let id = friendly_id::encode(&uuid);
assert_eq!(id, "5wbwf6yUxVBcr48AMbz9cb");

// Decode back to UUID
let decoded = friendly_id::decode(&id).unwrap();
assert_eq!(decoded, uuid);

Enums§

DecodeError
Errors that can occur when decoding a Base62 FriendlyID string.

Functions§

create
Creates a FriendlyID based on a random UUID v4.
decode
Decodes a FriendlyID string back to a UUID.
encode
Encodes a UUID to a FriendlyID string (Base62).