Skip to main content

DynViewPart

Trait DynViewPart 

Source
pub trait DynViewPart:
    'static
    + Debug
    + Send {
    // Required methods
    fn render(&self, cx: &Cx, w: &mut HtmlWriter<'_, '_>);
    fn clone_box(&self) -> Box<dyn DynViewPart>;

    // Provided method
    fn size_hint(&self) -> usize { ... }
}
Expand description

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

Implement this for values whose output is only known when the view renders, such as resolved asset URLs. The writer passed to render already carries the HtmlContext of the position the part was pushed into, so everything written through it is escaped or validated for that position.

Required Methods§

Source

fn render(&self, cx: &Cx, w: &mut HtmlWriter<'_, '_>)

Writes this part’s output into w.

Source

fn clone_box(&self) -> Box<dyn DynViewPart>

Clones this view part into a fresh boxed value.

Provided Methods§

Source

fn size_hint(&self) -> usize

Returns an estimate of the number of bytes this part will write.

Used to pre-allocate the output buffer, so aim for a close estimate. A slight over-estimate is usually preferable to an under-estimate.

Trait Implementations§

Source§

impl Clone for Box<dyn DynViewPart>

Source§

fn clone(&self) -> Self

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§