pub struct Fragment(/* private fields */);Expand description
A cached piece of HTML, from fragment or fragments.
It was rendered by an askama template, which escaped its values, so
templates write it as is: {{ row }} needs no |safe (it implements
askama’s HtmlSafe with feature html). Display
writes the HTML.
§Examples
use std::time::Duration;
use askama::Template;
use ocre::{Ctx, Result, cache::{self, Fragment}};
#[derive(Template)]
#[template(source = "<li>{{ title }}</li>", ext = "html")]
struct Row<'a> {
title: &'a str,
}
async fn row(ctx: &Ctx) -> Result<Fragment> {
let key = cache::key(&[&"posts", &12, &"2026-09-29 14:05:00", &"v1"]);
cache::fragment(ctx, &key, Duration::from_secs(86_400), || Row { title: "Hello" }).await
}Implementations§
Trait Implementations§
impl Eq for Fragment
impl HtmlSafe for Fragment
Available on crate feature
html only.Fragments are HTML rendered (and escaped) by askama templates.
impl StructuralPartialEq for Fragment
Auto Trait Implementations§
impl Freeze for Fragment
impl RefUnwindSafe for Fragment
impl Send for Fragment
impl Sync for Fragment
impl Unpin for Fragment
impl UnsafeUnpin for Fragment
impl UnwindSafe for Fragment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.