pub struct RenderCtx { /* private fields */ }Expand description
Rendering context: accumulates SQL string and parameters.
Provides a semantic, chainable API for building SQL output.
Implementations§
Source§impl RenderCtx
impl RenderCtx
pub fn new(param_style: ParamStyle) -> Self
pub fn with_parameterize(self, parameterize: bool) -> Self
Sourcepub fn parameterize(&self) -> bool
pub fn parameterize(&self) -> bool
Whether values should be rendered as parameter placeholders.
Sourcepub fn finish(self) -> (String, Vec<Value>)
pub fn finish(self) -> (String, Vec<Value>)
Consume the context and return the SQL string and parameters.
Sourcepub fn keyword(&mut self, kw: &str) -> &mut Self
pub fn keyword(&mut self, kw: &str) -> &mut Self
Write a SQL keyword. Adds a leading space if the buffer is non-empty
and doesn’t end with ( or whitespace.
Sourcepub fn param(&mut self, val: Value) -> &mut Self
pub fn param(&mut self, val: Value) -> &mut Self
Write a parameterized value. Appends the placeholder ($1, ?, etc.) and stores the value.
Sourcepub fn string_literal(&mut self, s: &str) -> &mut Self
pub fn string_literal(&mut self, s: &str) -> &mut Self
Write a string literal with proper escaping: 'value'.
Sourcepub fn paren_open(&mut self) -> &mut Self
pub fn paren_open(&mut self) -> &mut Self
Write opening parenthesis (, with space if needed.
Sourcepub fn paren_close(&mut self) -> &mut Self
pub fn paren_close(&mut self) -> &mut Self
Write closing parenthesis ).
Sourcepub fn write(&mut self, s: &str) -> &mut Self
pub fn write(&mut self, s: &str) -> &mut Self
Write arbitrary text (escape hatch, use sparingly).
Sourcepub fn raw_with_params(&mut self, sql: &str, params: &[Value]) -> &mut Self
pub fn raw_with_params(&mut self, sql: &str, params: &[Value]) -> &mut Self
Write raw SQL with %s placeholders, replacing them with
dialect-appropriate parameter markers and storing the values.
Escaping rules (Django-style):
%s→ dialect placeholder ($1,?,%s) + stores value%%→ literal%%%s→ literal%s(because%%becomes%, thensis just text)