Skip to main content

ViewPart

Enum ViewPart 

Source
#[non_exhaustive]
pub enum ViewPart {
Show 20 variants Empty,
#[non_exhaustive]
Bool(bool),
#[non_exhaustive]
I8(i8),
#[non_exhaustive]
I16(i16),
#[non_exhaustive]
I32(i32),
#[non_exhaustive]
I64(i64),
#[non_exhaustive]
I128(i128),
#[non_exhaustive]
Isize(isize),
#[non_exhaustive]
U8(u8),
#[non_exhaustive]
U16(u16),
#[non_exhaustive]
U32(u32),
#[non_exhaustive]
U64(u64),
#[non_exhaustive]
U128(u128),
#[non_exhaustive]
Usize(usize),
#[non_exhaustive]
F32(f32),
#[non_exhaustive]
F64(f64),
#[non_exhaustive]
Char { value: char, context: HtmlContext, },
#[non_exhaustive]
Str { value: Cow<'static, str>, context: HtmlContext, },
#[non_exhaustive]
BoxDyn { inner: Box<dyn DynViewPart>, context: HtmlContext, size_hint: usize, },
#[non_exhaustive]
BoxSlice { inner: Box<[ViewPart]>, size_hint: usize, },
}
Expand description

A renderable value stored in a View.

View parts are created through a PartsWriter or the view! macro. A part that holds text also records the HtmlContext it was written for, so rendering escapes or validates it for exactly that position.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Empty

Renders no content.

§

#[non_exhaustive]
Bool(bool)

A boolean rendered as text.

§

#[non_exhaustive]
I8(i8)

An i8 rendered as text.

§

#[non_exhaustive]
I16(i16)

An i16 rendered as text.

§

#[non_exhaustive]
I32(i32)

An i32 rendered as text.

§

#[non_exhaustive]
I64(i64)

An i64 rendered as text.

§

#[non_exhaustive]
I128(i128)

An i128 rendered as text.

§

#[non_exhaustive]
Isize(isize)

An isize rendered as text.

§

#[non_exhaustive]
U8(u8)

A u8 rendered as text.

§

#[non_exhaustive]
U16(u16)

A u16 rendered as text.

§

#[non_exhaustive]
U32(u32)

A u32 rendered as text.

§

#[non_exhaustive]
U64(u64)

A u64 rendered as text.

§

#[non_exhaustive]
U128(u128)

A u128 rendered as text.

§

#[non_exhaustive]
Usize(usize)

A usize rendered as text.

§

#[non_exhaustive]
F32(f32)

An f32 rendered as text.

§

#[non_exhaustive]
F64(f64)

An f64 rendered as text.

§

#[non_exhaustive]
Char

A character rendered for the recorded context.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§value: char
§context: HtmlContext
§

#[non_exhaustive]
Str

A string rendered for the recorded context.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§value: Cow<'static, str>
§context: HtmlContext
§

#[non_exhaustive]
BoxDyn

A custom view part that writes its output at render time.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§inner: Box<dyn DynViewPart>
§context: HtmlContext
§size_hint: usize
§

#[non_exhaustive]
BoxSlice

A sequence of view parts rendered in order.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§inner: Box<[ViewPart]>
§size_hint: usize

Implementations§

Source§

impl ViewPart

Source

pub fn empty() -> Self

Returns an empty view part.

Source

pub fn is_empty(&self) -> bool

Returns true if the view part is Empty.

Trait Implementations§

Source§

impl AttributeValueViewParts for ViewPart

Source§

fn attribute_present(&self) -> bool

Returns whether the containing attribute should be rendered. Read more
Source§

fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)

Appends this attribute value to the view being built.
Source§

impl AttributeViewParts for ViewPart

Source§

fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)

Appends zero or more attributes to the view being built.
Source§

impl ClassViewParts for ViewPart

An attribute value, such as one taken from an Attributes collection with get, spliced in as a single entry.

Source§

fn is_present(&self) -> bool

Returns whether this value contributes to the class list. Read more
Source§

fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)

Appends this value to the class list being built.
Source§

impl ClassViewParts for &ViewPart

Source§

fn is_present(&self) -> bool

Returns whether this value contributes to the class list. Read more
Source§

fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)

Appends this value to the class list being built.
Source§

impl Clone for ViewPart

Source§

fn clone(&self) -> ViewPart

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ViewPart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ViewPart

Source§

fn default() -> ViewPart

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> ClassEntries for T
where T: ClassViewParts,

Source§

fn any_present(&self) -> bool

Returns whether any entry contributes to the class list.
Source§

fn write_entries(self, cx: &Cx, writer: &mut ClassWriter<'_, '_>)

Writes every entry through writer.
Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.