Skip to main content

from_fn

Function from_fn 

Source
pub fn from_fn<F>(f: F) -> RenderFn
where F: FnMut(&Value) -> Result<String, RenderError> + 'static,
Expand description

Creates a render function from a closure.

This is the primary way to provide custom rendering logic. The closure should capture any context it needs (format, theme, templates, etc.).

Accepts FnMut closures, allowing mutable state in the render handler.

ยงExample

use standout_dispatch::{from_fn, RenderError};

let render = from_fn(|data| {
    Ok(serde_json::to_string_pretty(data)?)
});