Servable

Trait Servable 

Source
pub trait Servable: Send + Sync {
    // Required methods
    fn head<'a>(
        &'a self,
        ctx: &'a RenderContext,
    ) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>;
    fn render<'a>(
        &'a self,
        ctx: &'a RenderContext,
    ) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>;
}
Expand description

Something that may be served over http. If implementing this trait, refer to sample implementations in redirect::Redirect, asset::StaticAsset and html::HtmlPage.

Required Methods§

Source

fn head<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>

Return the same response as Servable::render, but with an empty body.

This method is used to respond to HEAD requests.

Source

fn render<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>

Render this page. Must return the same metadata as Servable::head. Consider using crate::Rendered::with_body and Servable::head to implement this fn.

This method is used to respond to GET requests.

Implementations on Foreign Types§

Source§

impl<S: Servable> Servable for &'static S

Source§

fn head<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>

Source§

fn render<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>

Source§

impl<S: Servable> Servable for LazyLock<S>

Source§

fn head<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>

Source§

fn render<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>

Implementors§

Source§

impl Servable for HtmlPage

Source§

impl Servable for Redirect

Source§

impl Servable for StaticAsset

Available on non-crate feature image only.
Source§

impl<S: Servable> Servable for ServableWithRoute<S>