pub trait CompiledGenerator: Send {
// Required method
fn generate(
&mut self,
context: &RowContext<'_>,
output: &mut GeneratedValue,
) -> Result<(), GenerateError>;
// Provided methods
fn key_recipe(&self) -> Option<KeyRecipe> { ... }
fn is_inherently_unique(&self) -> bool { ... }
}Expand description
A compiled generator: produces one value per row into a caller-owned slot.
Required Methods§
Sourcefn generate(
&mut self,
context: &RowContext<'_>,
output: &mut GeneratedValue,
) -> Result<(), GenerateError>
fn generate( &mut self, context: &RowContext<'_>, output: &mut GeneratedValue, ) -> Result<(), GenerateError>
Overwrite output with the value for the current row. Overwriting
(rather than returning) lets the engine reuse the allocation across
rows.
Provided Methods§
Sourcefn key_recipe(&self) -> Option<KeyRecipe>
fn key_recipe(&self) -> Option<KeyRecipe>
How this generator materializes as a random-access key when its column
is a primary key referenced by a child foreign key. The default is
None (not a reproducible random-access key — the engine then reports
GEN-KEY-DOMAIN-UNSUPPORTED). A generator whose row n value is a
closed-form or per-row-reseeded function of n overrides this so the
engine can regenerate any parent row’s key by index.
Sourcefn is_inherently_unique(&self) -> bool
fn is_inherently_unique(&self) -> bool
Whether this generator produces distinct values by construction (or
collides only negligibly), so a single-column key needs no auto-attached
unique modifier — and, crucially, is not capped by that modifier’s
max_tracked budget on tables larger than it. The default is any
generator with a KeyRecipe (sequence is dense, uuid collides
negligibly). A high-entropy random generator (a long nanoid, ulid,
token, or hash) or a monotonic counter overrides this to true; a
short, low-entropy random string leaves it false so it is still tracked.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".