Skip to main content

from_fn

Function from_fn 

Source
pub fn from_fn<F>(f: F) -> RenderFn
where F: Fn(&Value) -> Result<String, RenderError> + Send + Sync + '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.).

ยงExample

use standout_dispatch::{from_fn, RenderError};

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