Skip to main content

Schema

Trait Schema 

Source
pub trait Schema {
    // Required methods
    fn name() -> &'static str;
    fn copy() -> &'static str;
    fn creates() -> &'static str;
    fn indices() -> &'static str;
    fn truncates() -> &'static str;
    fn freeze() -> &'static str;
    fn columns() -> &'static [Type];
}
Expand description

Schema metadata for PostgreSQL tables.

Provides compile-time SQL generation for table creation, indexing, and bulk data operations. All methods return &'static str to avoid runtime allocations and enable compile-time string construction via const_format::concatcp!.

§Design

This trait contains no I/O operations—it purely describes table structure. Actual database operations are handled by Streamable and Hydrate.

Required Methods§

Source

fn name() -> &'static str

Returns the table name in the database.

Source

fn copy() -> &'static str

Returns the COPY ... FROM STDIN BINARY command for bulk loading.

Source

fn creates() -> &'static str

Returns CREATE TABLE IF NOT EXISTS DDL statement.

Source

fn indices() -> &'static str

Returns CREATE INDEX IF NOT EXISTS statements for all indices.

Source

fn truncates() -> &'static str

Returns TRUNCATE TABLE statement for clearing data.

Source

fn freeze() -> &'static str

Returns SQL to optimize table for read-heavy workloads.

Typically sets fillfactor = 100 and disables autovacuum for tables that are bulk-loaded once and never modified.

Source

fn columns() -> &'static [Type]

Returns PostgreSQL column types for binary COPY protocol.

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 Schema for Street

Source§

fn name() -> &'static str

Source§

fn creates() -> &'static str

Source§

fn indices() -> &'static str

Source§

fn copy() -> &'static str

Source§

fn truncates() -> &'static str

Source§

fn freeze() -> &'static str

Source§

fn columns() -> &'static [Type]

Source§

impl Schema for Abstraction

Source§

fn name() -> &'static str

Source§

fn creates() -> &'static str

Source§

fn indices() -> &'static str

Source§

fn copy() -> &'static str

Source§

fn truncates() -> &'static str

Source§

fn freeze() -> &'static str

Source§

fn columns() -> &'static [Type]

Implementors§