Trait mas_templates::TemplateContext
source · pub trait TemplateContext: Serialize {
// Required method
fn sample(now: DateTime<Utc>, rng: &mut impl Rng) -> Vec<Self>
where Self: Sized;
// Provided methods
fn with_session(self, current_session: BrowserSession) -> WithSession<Self>
where Self: Sized { ... }
fn maybe_with_session(
self,
current_session: Option<BrowserSession>,
) -> WithOptionalSession<Self>
where Self: Sized { ... }
fn with_csrf<C>(self, csrf_token: C) -> WithCsrf<Self>
where Self: Sized,
C: ToString { ... }
fn with_language(self, lang: DataLocale) -> WithLanguage<Self>
where Self: Sized { ... }
fn with_captcha(self, captcha: Option<CaptchaConfig>) -> WithCaptcha<Self>
where Self: Sized { ... }
}
Expand description
Helper trait to construct context wrappers
Required Methods§
Provided Methods§
sourcefn with_session(self, current_session: BrowserSession) -> WithSession<Self>where
Self: Sized,
fn with_session(self, current_session: BrowserSession) -> WithSession<Self>where
Self: Sized,
Attach a user session to the template context
sourcefn maybe_with_session(
self,
current_session: Option<BrowserSession>,
) -> WithOptionalSession<Self>where
Self: Sized,
fn maybe_with_session(
self,
current_session: Option<BrowserSession>,
) -> WithOptionalSession<Self>where
Self: Sized,
Attach an optional user session to the template context
sourcefn with_csrf<C>(self, csrf_token: C) -> WithCsrf<Self>
fn with_csrf<C>(self, csrf_token: C) -> WithCsrf<Self>
Attach a CSRF token to the template context
sourcefn with_language(self, lang: DataLocale) -> WithLanguage<Self>where
Self: Sized,
fn with_language(self, lang: DataLocale) -> WithLanguage<Self>where
Self: Sized,
Attach a language to the template context
sourcefn with_captcha(self, captcha: Option<CaptchaConfig>) -> WithCaptcha<Self>where
Self: Sized,
fn with_captcha(self, captcha: Option<CaptchaConfig>) -> WithCaptcha<Self>where
Self: Sized,
Attach a CAPTCHA configuration to the template context
Object Safety§
This trait is not object safe.