Skip to main content

RenderFn

Type Alias RenderFn 

Source
pub type RenderFn = Arc<dyn Fn(&Value) -> Result<String, RenderError> + Send + Sync>;
Expand description

The render function signature.

Takes handler data (as JSON) and returns formatted output. The render function is a closure that captures all rendering context (format, theme, templates, etc.) so dispatch doesn’t need to know about any of it.

§Example

// Framework creates render handler with context captured
let render_handler = from_fn(move |data| {
    match format {
        Format::Json => serde_json::to_string_pretty(data),
        Format::Term => render_template(template, data, theme),
        // ...
    }
});

Aliased Type§

pub struct RenderFn { /* private fields */ }