View Source Avrogen.Util.Random.Constructors (avrogen v0.8.1)
Provides functions that return "constructor functions". A constructor function is a function that expects a rand_state and optional parameters, and, on invocation, returns an updated rand_state and a randomly generated value.
The functions in this module are basically 'lazy' wrappers around eager functions in the parent module.
Thanks to this 'laziness', we can specify lists of alternative constructor functions, from which we can randomly choose an element for evaluation (without forcing all elements to be evaluated up front).
Summary
Functions
Instantiates a struct with random values as per the given constructors list. Returns the updated rand_state and the instantiated struct.
Types
@type constructor_fun() :: (Avrogen.Util.Random.rand_state() -> {Avrogen.Util.Random.rand_state(), any()})
@type constructor_list() :: {atom(), constructor_fun()} | {atom(), [constructor_fun()]}
Functions
@spec boolean() :: constructor_fun()
@spec date(Keyword.t()) :: constructor_fun()
@spec datetime(Keyword.t()) :: constructor_fun()
@spec decimal(Keyword.t()) :: constructor_fun()
@spec enum_value(atom()) :: constructor_fun()
@spec float(Keyword.t()) :: constructor_fun()
@spec instantiate( Avrogen.Util.Random.rand_state(), module() | struct(), maybe_improper_list() ) :: {Avrogen.Util.Random.rand_state(), struct()}
Instantiates a struct with random values as per the given constructors list. Returns the updated rand_state and the instantiated struct.
@spec integer(Keyword.t()) :: constructor_fun()
@spec list(constructor_fun(), integer()) :: constructor_fun()
@spec nothing() :: constructor_fun()
@spec string(Keyword.t()) :: constructor_fun()
@spec time(Keyword.t()) :: constructor_fun()