Skip to main content

PartsWriter

Struct PartsWriter 

Source
pub struct PartsWriter<'a> { /* private fields */ }
Expand description

A context-carrying writer over a view-parts buffer, created per position.

The view! macro creates a PartsWriter for each dynamic position it fills and hands it to the matching position trait: NodeViewParts, AttributeValueViewParts, AttributeKeyViewParts, ElementNameViewParts, or AttributeViewParts.

Implementations of those traits make a value renderable by pushing it through the push_* methods, which seal the pushed text with the HtmlContext of the position so rendering escapes or validates it correctly, or by delegating to another implementation of the same position trait. push_str_unescaped is the only way to opt out of that protection.

Implementations§

Source§

impl<'a> PartsWriter<'a>

Source

pub fn new(parts: &'a mut ViewParts, context: HtmlContext) -> Self

Creates a writer that seals everything pushed into it with context.

Source

pub fn push_str(&mut self, value: impl Into<Cow<'static, str>>) -> &mut Self

Appends a string, sealed with this writer’s context.

Source

pub fn push_str_unescaped( &mut self, value: impl Into<Cow<'static, str>>, ) -> &mut Self

Appends a string that renders verbatim, bypassing this writer’s context.

Use this only for trusted markup. Passing untrusted input defeats the runtime’s escaping and can lead to XSS vulnerabilities.

Source

pub fn push_char(&mut self, value: char) -> &mut Self

Appends a character, sealed with this writer’s context.

Source

pub fn push_bool(&mut self, value: bool) -> &mut Self

Appends a bool rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_i8(&mut self, value: i8) -> &mut Self

Appends a i8 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_i16(&mut self, value: i16) -> &mut Self

Appends a i16 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_i32(&mut self, value: i32) -> &mut Self

Appends a i32 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_i64(&mut self, value: i64) -> &mut Self

Appends a i64 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_i128(&mut self, value: i128) -> &mut Self

Appends a i128 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_isize(&mut self, value: isize) -> &mut Self

Appends a isize rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_u8(&mut self, value: u8) -> &mut Self

Appends a u8 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_u16(&mut self, value: u16) -> &mut Self

Appends a u16 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_u32(&mut self, value: u32) -> &mut Self

Appends a u32 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_u64(&mut self, value: u64) -> &mut Self

Appends a u64 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_u128(&mut self, value: u128) -> &mut Self

Appends a u128 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_usize(&mut self, value: usize) -> &mut Self

Appends a usize rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_f32(&mut self, value: f32) -> &mut Self

Appends a f32 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_f64(&mut self, value: f64) -> &mut Self

Appends a f64 rendered as text.

Its rendered form contains no character that is significant in any HTML context, so no escaping applies.

Source

pub fn push_dyn(&mut self, part: Box<dyn DynViewPart>) -> &mut Self

Appends a part that writes its output at render time, sealed with this writer’s context.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PartsWriter<'a>

§

impl<'a> !Sync for PartsWriter<'a>

§

impl<'a> !UnwindSafe for PartsWriter<'a>

§

impl<'a> Freeze for PartsWriter<'a>

§

impl<'a> Send for PartsWriter<'a>

§

impl<'a> Unpin for PartsWriter<'a>

§

impl<'a> UnsafeUnpin for PartsWriter<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.