pub struct HtmlPage {
pub meta: PageMetadata,
pub private: bool,
pub ttl: Option<TimeDelta>,
pub render: Arc<dyn Send + Sync + for<'a> Fn(&'a HtmlPage, &'a RenderContext) -> Pin<Box<dyn Future<Output = Markup> + Send + Sync + 'a>> + 'static>,
pub response_code: StatusCode,
pub scripts: Vec<ScriptSource<String>>,
pub styles: Vec<ScriptSource<String>>,
pub extra_meta: Vec<(String, String)>,
}Expand description
A complete, dynamically-rendered blob of HTML.
Fields§
§meta: PageMetadataThis page’s metadata
private: boolIf true, the contents of this page never change
ttl: Option<TimeDelta>How long this page’s html may be cached. This controls the maximum age of a page shown to the user.
If None, this page is never cached.
render: Arc<dyn Send + Sync + for<'a> Fn(&'a HtmlPage, &'a RenderContext) -> Pin<Box<dyn Future<Output = Markup> + Send + Sync + 'a>> + 'static>A function that generates this page’s html.
This should return the contents of this page’s
This closure must never return <html> or <head>.
response_code: StatusCodeThe response code that should accompany this html
scripts: Vec<ScriptSource<String>>Scripts to include in this page. Order is preserved.
styles: Vec<ScriptSource<String>>Styles to include in this page. Order is preserved.
extra_meta: Vec<(String, String)>name, content for extra <meta> tags
Implementations§
Source§impl HtmlPage
impl HtmlPage
Sourcepub fn with_meta(self, meta: PageMetadata) -> Self
pub fn with_meta(self, meta: PageMetadata) -> Self
Set self.meta
Sourcepub fn with_render<R: Send + Sync + 'static + for<'a> Fn(&'a HtmlPage, &'a RenderContext) -> Pin<Box<dyn Future<Output = Markup> + Send + Sync + 'a>>>(
self,
render: R,
) -> Self
pub fn with_render<R: Send + Sync + 'static + for<'a> Fn(&'a HtmlPage, &'a RenderContext) -> Pin<Box<dyn Future<Output = Markup> + Send + Sync + 'a>>>( self, render: R, ) -> Self
Set self.generate
Sourcepub fn with_private(self, private: bool) -> Self
pub fn with_private(self, private: bool) -> Self
Set self.private
Sourcepub fn with_code(self, response_code: StatusCode) -> Self
pub fn with_code(self, response_code: StatusCode) -> Self
Set self.response_code
Sourcepub fn with_script_inline(self, script: impl Into<String>) -> Self
pub fn with_script_inline(self, script: impl Into<String>) -> Self
Add an inline script to this page (after existing scripts)
Sourcepub fn with_script_linked(self, url: impl Into<String>) -> Self
pub fn with_script_linked(self, url: impl Into<String>) -> Self
Add a linked script to this page (after existing scripts)
Sourcepub fn with_script(self, script: ScriptSource<impl Into<String>>) -> Self
pub fn with_script(self, script: ScriptSource<impl Into<String>>) -> Self
Add a script to this page (after existing scripts)
Sourcepub fn with_style_inline(self, style: impl Into<String>) -> Self
pub fn with_style_inline(self, style: impl Into<String>) -> Self
Add an inline script to this page (after existing styles)
Sourcepub fn with_style_linked(self, url: impl Into<String>) -> Self
pub fn with_style_linked(self, url: impl Into<String>) -> Self
Add a linked style to this page (after existing styles)
Sourcepub fn with_style(self, style: ScriptSource<impl Into<String>>) -> Self
pub fn with_style(self, style: ScriptSource<impl Into<String>>) -> Self
Add a style to this page (after existing scripts)