createIdGenerator
Build an id generator with a prefix and alphabet.
Returns a generator producing ids with the prefix, alphabet, size, and
separator you choose. Useful when ids need to be recognizable per surface, like
msg_ and call_.
let nextID = createIdGenerator(prefix: "msg", size: 16)
let id = nextID()Signature
func createIdGenerator(
prefix: String? = nil,
separator: String = "-",
alphabet: String = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
size: Int = 16
) -> @Sendable () -> StringDefined in Sources/AI/Core/RuntimeContext.swift.
Parameters
| Parameter | Type | Default |
|---|---|---|
prefix | String? | nil |
separator | String | "-" |
alphabet | String | "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
size | Int | 16 |
Returns
A @Sendable () -> String.