pub trait SqlTemplate<'q, DB>: Sized + Clonewhere
DB: Database,{
// Required method
fn render_sql_with_encode_placeholder_fn(
self,
f: Option<fn(usize, &mut String)>,
sql_buffer: &mut String,
) -> Result<Option<DB::Arguments<'q>>, Error>;
// Provided methods
fn render_sql(self) -> Result<(String, Option<DB::Arguments<'q>>), Error> { ... }
fn render_executeable(
self,
sql_buffer: &'q mut String,
) -> Result<SqlTemplateExecute<'q, DB>, Error> { ... }
fn render_db_adapter_manager(
self,
_sql_buff: &'q mut String,
) -> DBAdapterManager<'q, DB, Self> { ... }
fn adapter_render(self) -> DBAdapterManager<'q, DB, Self> { ... }
}Expand description
SQL template trait
Defines basic operations for rendering SQL from templates
Required Methods§
Sourcefn render_sql_with_encode_placeholder_fn(
self,
f: Option<fn(usize, &mut String)>,
sql_buffer: &mut String,
) -> Result<Option<DB::Arguments<'q>>, Error>
fn render_sql_with_encode_placeholder_fn( self, f: Option<fn(usize, &mut String)>, sql_buffer: &mut String, ) -> Result<Option<DB::Arguments<'q>>, Error>
Renders the SQL template using a custom placeholder encoding function
Writes the rendered SQL to the provided buffer and handles parameter encoding. The placeholder function (if provided) formats parameter placeholders (e.g., $1, ?) based on their index.
§Parameters
f: Optional function to format parameter placeholders (receives index and buffer)sql_buffer: Mutable string buffer to store the rendered SQL
§Returns
Encoded database arguments (None if no parameters) or an error if rendering fails
Provided Methods§
Sourcefn render_sql(self) -> Result<(String, Option<DB::Arguments<'q>>), Error>
fn render_sql(self) -> Result<(String, Option<DB::Arguments<'q>>), Error>
Renders SQL template and returns query string with parameters
Sourcefn render_executeable(
self,
sql_buffer: &'q mut String,
) -> Result<SqlTemplateExecute<'q, DB>, Error>
fn render_executeable( self, sql_buffer: &'q mut String, ) -> Result<SqlTemplateExecute<'q, DB>, Error>
Renders SQL template and returns executable query result
fn render_db_adapter_manager( self, _sql_buff: &'q mut String, ) -> DBAdapterManager<'q, DB, Self>
adapter_render insteadSourcefn adapter_render(self) -> DBAdapterManager<'q, DB, Self>
fn adapter_render(self) -> DBAdapterManager<'q, DB, Self>
Creates a database adapter manager for the template
Provides an adapter pattern interface for managing template rendering in database-specific scenarios.
§Returns
A new DBAdapterManager instance wrapping the template
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.