Skip to main content

CompiledGenerator

Trait CompiledGenerator 

Source
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§

Source

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§

Source

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.

Source

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".

Implementors§