Skip to main content

RenderExt

Trait RenderExt 

Source
pub trait RenderExt: Render {
    // Required method
    fn displayed<'a>(&'a self, ctx: &'a RenderCtx<'a>) -> Displayed<'a, Self>
       where Self: Sized;

    // Provided method
    fn debug_sql<'a>(&'a self, resolver: &'a dyn Resolver) -> DebugSql<'a, Self>
       where Self: Sized { ... }
}
Expand description

Ergonomic constructors for the Displayed and DebugSql adapters, blanket-impl’d for every Render type.

Required Methods§

Source

fn displayed<'a>(&'a self, ctx: &'a RenderCtx<'a>) -> Displayed<'a, Self>
where Self: Sized,

Pair this node with an explicit canonical RenderCtx so format!, to_string, and {} render it. This is the canonical path: the ctx’s resolver and source must match the node’s parse.

Provided Methods§

Source

fn debug_sql<'a>(&'a self, resolver: &'a dyn Resolver) -> DebugSql<'a, Self>
where Self: Sized,

Render this node for debugging against an explicitly-supplied resolver (the debug-SQL mitigation), returning a Display adapter.

Reach for this only for a detached or synthesized node — one not behind a Parsed root and possibly holding symbols the resolver on hand does not own. Prefer the canonical path first: the Parsed root’s Display and displayed render exact SQL because they travel with the matched source and resolver, and cannot mismatch.

This helper trades exactness for safety on a detached node:

  • The resolver is an explicit argument — never a hidden thread-local, global, or default — so it can never silently render with the wrong resolver: the choice is always written at the call site.
  • A symbol the resolver does not know renders as <unresolved> rather than panicking, so a partially-detached tree still prints to completion.
  • Literals use their kind-based spelling (0, '', NULL, …): debug rendering never slices source, so it cannot emit unrelated bytes.

Limitation. An explicit argument cannot detect a resolver from a different parse: a symbol whose numeric id happens to collide with an entry in that resolver resolves to the other parse’s text. The helper prevents a silent choice of the wrong resolver and turns unknown symbols into a visible placeholder, but only the canonical path — which owns its own matched resolver — rules a colliding foreign resolver out entirely.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Render> RenderExt for T