friendly_id/encoding

Types

pub type EncodingError {
  OutOfBounds
}

Constructors

  • OutOfBounds

Values

pub fn encode_int(
  generator: generator.Generator,
  id: Int,
) -> Result(String, EncodingError)

Encodes an int to a Friendly ID. This is a deterministic operation, which means an int will always return the same ID, and guarantees no collisions.

Examples

Create a generator with defaults, then generate an ID by encoding an int

let generator = generator.new()
echo encoding.encode_int(generator, 23)
pub fn encoder_max_int(generator: generator.Generator) -> Int
Search Document