Skip to main content

RenderCtx

Struct RenderCtx 

Source
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

Source

pub fn new(param_style: ParamStyle) -> Self

Source

pub fn with_parameterize(self, parameterize: bool) -> Self

Source

pub fn parameterize(&self) -> bool

Whether values should be rendered as parameter placeholders.

Source

pub fn finish(self) -> (String, Vec<Value>)

Consume the context and return the SQL string and parameters.

Source

pub fn sql(&self) -> &str

Get the current SQL string (for inspection).

Source

pub fn params(&self) -> &[Value]

Get the current parameters (for inspection).

Source

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.

Source

pub fn ident(&mut self, name: &str) -> &mut Self

Write a quoted identifier: "name".

Source

pub fn param(&mut self, val: Value) -> &mut Self

Write a parameterized value. Appends the placeholder ($1, ?, etc.) and stores the value.

Source

pub fn string_literal(&mut self, s: &str) -> &mut Self

Write a string literal with proper escaping: 'value'.

Source

pub fn operator(&mut self, op: &str) -> &mut Self

Write an operator: ::, =, >, ||, etc.

Source

pub fn paren_open(&mut self) -> &mut Self

Write opening parenthesis (, with space if needed.

Source

pub fn paren_close(&mut self) -> &mut Self

Write closing parenthesis ).

Source

pub fn comma(&mut self) -> &mut Self

Write a comma separator , .

Source

pub fn space(&mut self) -> &mut Self

Write an explicit space.

Source

pub fn write(&mut self, s: &str) -> &mut Self

Write arbitrary text (escape hatch, use sparingly).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.