pub struct Trusted(/* private fields */);Expand description
A string that is markup, and is written into a document unescaped.
The invariant is the whole type: whatever is inside is already safe to
appear between tags. Every way of building one either escapes what it is
given (escaping, push) or is an
explicit claim by the caller (from_markup,
to_trusted) — so the places worth auditing are
exactly the ones that name trust.
Implementations§
Source§impl Trusted
impl Trusted
Sourcepub const fn from_markup(markup: String) -> Self
pub const fn from_markup(markup: String) -> Self
Take markup as markup, unescaped.
This is the claim. It is const and free — no scan, no copy — because
the point of the type is to make the claim once, where the markup is
built, rather than at every place it is written.
Sourcepub fn escaping(value: &dyn Display) -> Self
pub fn escaping(value: &dyn Display) -> Self
Escape value into a new document.
The inverse of from_markup: this one is always
safe, whatever the value came from.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Take the markup, giving up the claim that it is markup.
Sourcepub fn push(&mut self, content: &impl Content)
pub fn push(&mut self, content: &impl Content)
Append content, escaping it if it is not already markup.
This is SafeBuffer#<<: a &str arrives escaped, another
Trusted arrives whole, and neither call site has to remember which.
Sourcepub fn push_markup(&mut self, markup: &str)
pub fn push_markup(&mut self, markup: &str)
Append markup unescaped — the claim from_markup
makes, for a document being built up.
Sourcepub fn push_escaped(&mut self, value: &dyn Display)
pub fn push_escaped(&mut self, value: &dyn Display)
Append value’s Display output, escaped.
Trait Implementations§
Source§impl Content for Trusted
impl Content for Trusted
Source§fn write_content(&self, out: &mut Trusted)
fn write_content(&self, out: &mut Trusted)
out, escaping it unless it is already markup.impl Eq for Trusted
Source§impl Ord for Trusted
impl Ord for Trusted
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Trusted
impl PartialOrd for Trusted
Source§impl Render for Trusted
impl Render for Trusted
Source§fn render_into(&self, r: &mut dyn Renderer)
fn render_into(&self, r: &mut dyn Renderer)
r, with no slots filled.impl StructuralPartialEq for Trusted
Auto Trait Implementations§
impl Freeze for Trusted
impl RefUnwindSafe for Trusted
impl Send for Trusted
impl Sync for Trusted
impl Unpin for Trusted
impl UnsafeUnpin for Trusted
impl UnwindSafe for Trusted
Blanket Implementations§
Source§impl<T> AsyncRender for T
impl<T> AsyncRender for T
Source§fn render_into_async<'life0, 'life1, 'async_trait>(
&'life0 self,
r: &'life1 mut dyn Renderer,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait,
fn render_into_async<'life0, 'life1, 'async_trait>(
&'life0 self,
r: &'life1 mut dyn Renderer,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait,
r, with no slots filled.