Skip to content

rand.cuid2 #

fn is_cuid #

fn is_cuid(cuid string) bool

is_cuid Checks whether a given cuid has a valid form and length

fn new #

fn new(param Cuid2Param) Cuid2Generator

new Create a cuid2 UUID generator.

struct Cuid2Generator #

struct Cuid2Generator {
mut:
	// A counter that will be used to affect the entropy of
	// successive id generation calls
	session_counter i64
	// A unique string that will be used by the Cuid generator
	// to help prevent collisions when generating Cuids in a
	// distributed system.
	fingerprint string
pub mut:
	// A PRNG that has a PRNG interface
	prng &rand.PRNG = rand.get_current_rng()
	// Length of the generated Cuid, min = 2, max = 32, default = 24
	length int = default_id_length
}

Cuid2Generator Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs.

fn (Cuid2Generator) generate #

fn (mut g Cuid2Generator) generate() string

generate Generate a new cuid2 UUID. It is an alias to function cuid2()

fn (Cuid2Generator) cuid2 #

fn (mut g Cuid2Generator) cuid2() string

cuid2 generates a random (cuid2) UUID. Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs. Ported from https://github.com/paralleldrive/cuid2

fn (Cuid2Generator) next #

fn (mut g Cuid2Generator) next() ?string

next Generate a new cuid2 UUID. It is an alias to function cuid2()

struct Cuid2Param #

@[params]
struct Cuid2Param {
pub mut:
	// A PRNG that has a PRNG interface
	prng &rand.PRNG = rand.get_current_rng()
	// Length of the generated Cuid, min = 2, max = 32, default = 24
	length int = default_id_length
}