veer 0.1.1

Inertia.js v3 server-side protocol superset for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Adapter from a closure to a `RootView`.

use super::{RootView, RootViewContext};

/// Wrap any `Fn(RootViewContext<'_>) -> Result<String, String>` as a `RootView`.
pub struct ClosureRootView<F>(pub F);

impl<F> RootView for ClosureRootView<F>
where
    F: Fn(RootViewContext<'_>) -> Result<String, String> + Send + Sync,
{
    fn render(&self, ctx: RootViewContext<'_>) -> Result<String, String> {
        (self.0)(ctx)
    }
}