pub struct Shell { /* private fields */ }Expand description
The chrome shared by every authenticated page: the top-nav links and the
signed-in operator. Built once by the auth guard and injected into request
extensions, so page handlers render inside the same shell without each
rebuilding it. Templates embed it as shell and base.html renders it.
A contributed screen takes it as Extension<Shell> and renders its own
markup inside the chrome with Shell::page; Shell::t localizes its
strings and Shell::csrf_token arms a form it builds by hand.
Implementations§
Source§impl Shell
impl Shell
Sourcepub fn icon(&self, name: &str) -> String
pub fn icon(&self, name: &str) -> String
Inline SVG for a named icon from the framework’s set, for a template’s
own chrome ({{ shell.icon("folder")|safe }}). An unknown name renders
the missing mark.
Sourcepub fn t(&self, source: &str) -> String
pub fn t(&self, source: &str) -> String
Localizes a source string in this request’s locale, falling back to the
source itself. Templates call {{ shell.t("Save") }}.
Sourcepub fn tt(&self, text: &Text) -> String
pub fn tt(&self, text: &Text) -> String
Localizes a prebuilt message (a t!/tn! value, a descriptor label, a
flash) into this request’s locale.
Sourcepub fn i18n(&self) -> &Translator
pub fn i18n(&self) -> &Translator
The request’s translator, for a field type that localizes strings of its own (a repeater’s sub-field labels) rather than only the label it is given.
Sourcepub fn csrf_token(&self) -> &str
pub fn csrf_token(&self) -> &str
This session’s request token, for a form a screen builds by hand: a
hidden field named _csrf, placed first when the form uploads a file.
An HTMX request carries it already.
Sourcepub fn datetime(&self, utc: &str) -> String
pub fn datetime(&self, utc: &str) -> String
A UTC timestamp as stored (RFC 3339), shown in this operator’s timezone. Text that does not parse is shown as it is.
Sourcepub fn page(&self, title: &Text, body: Markup) -> Response
pub fn page(&self, title: &Text, body: Markup) -> Response
Renders body as a page in the admin chrome, headed by title. The
body is a screen’s own markup, built from its templates through
html::Markup::from_template.
Sourcepub fn page_with(&self, head: PageHead, body: Markup) -> Response
pub fn page_with(&self, head: PageHead, body: Markup) -> Response
A contributed page with a PageHead: the title, a way back and the
actions beside it, then body inside the chrome.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shell
impl RefUnwindSafe for Shell
impl Send for Shell
impl Sync for Shell
impl Unpin for Shell
impl UnsafeUnpin for Shell
impl UnwindSafe for Shell
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
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more