pub trait QueryFragmentForCachedStatement<DB> {
    // Required methods
    fn construct_sql(&self, backend: &DB) -> QueryResult<String>;
    fn is_safe_to_cache_prepared(&self, backend: &DB) -> QueryResult<bool>;
}
Expand description

Implemented for all QueryFragments, dedicated to dynamic dispatch within the context of statement_cache

We want the generated code to be as small as possible, so for each query passed to StatementCache::cached_statement the generated assembly will just call a non generic version with dynamic dispatch pointing to the VTABLE of this minimal trait

This preserves the opportunity for the compiler to entirely optimize the construct_sql function as a function that simply returns a constant String.

Required Methods§

source

fn construct_sql(&self, backend: &DB) -> QueryResult<String>

Convert the query fragment into a SQL string for the given backend

source

fn is_safe_to_cache_prepared(&self, backend: &DB) -> QueryResult<bool>

Check whether it’s safe to cache the query

Implementors§