hashira 0.0.2-alpha

A server side rendering framework build on top of Yew
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{app::RequestContext, error::BoxError};

/// A hook to the application when rendering a chunk of html,
/// this may be a chunk of a HTML being streamed or after the complete html had been rendered.
pub trait OnChunkRender {
    /// Called when rendering a chunk of html.
    fn call(&self, chunk: String, ctx: RequestContext) -> Result<String, BoxError>;
}

impl<F> OnChunkRender for F
where
    F: Fn(String, RequestContext) -> Result<String, BoxError> + Send + Sync + 'static,
{
    fn call(&self, chunk: String, ctx: RequestContext) -> Result<String, BoxError> {
        (self)(chunk, ctx)
    }
}