pub trait TemplateContext: Serialize {
// Required method
fn sample<R: Rng>(
now: DateTime<Utc>,
rng: &mut R,
locales: &[DataLocale],
) -> BTreeMap<SampleIdentifier, 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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".