Skip to main content

Derive

Trait Derive 

Source
pub trait Derive: Sized + Schema {
    // Required methods
    fn exhaust() -> Vec<Self>;
    fn inserts(&self) -> String;

    // Provided method
    fn derives() -> String { ... }
}
Expand description

Derived table generation from enumerable domain values.

For tables whose contents can be exhaustively enumerated at runtime (e.g., street configurations, abstraction definitions), this trait generates INSERT statements programmatically.

§Usage

Implement exhaust to enumerate all valid values, and inserts to format each as an INSERT statement. The derives method combines these into a single SQL batch.

§Contrast with Streamable

Use Derive for small, enumerable tables where INSERT is sufficient. Use Streamable for large datasets requiring binary COPY performance.

Required Methods§

Source

fn exhaust() -> Vec<Self>

Enumerates all values that should be inserted into the table.

Source

fn inserts(&self) -> String

Formats this value as an INSERT statement.

Provided Methods§

Source

fn derives() -> String

Generates a batch of INSERT statements for all enumerated values.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Derive for Street

Source§

fn exhaust() -> Vec<Self>

Source§

fn inserts(&self) -> String

Source§

impl Derive for Abstraction

Source§

fn exhaust() -> Vec<Self>

Source§

fn inserts(&self) -> String

Implementors§