Skip to main content

Fill

Enum Fill 

Source
pub enum Fill<'a> {
    Ready(&'a (dyn Render + Sync)),
    Awaiting(&'a (dyn AsyncRender + Sync)),
}
Expand description

One slot’s content, and whether producing it suspends.

Two shapes rather than one because there is no way to run a future to completion from inside a synchronous render: an awaiting fill can only be written by a caller that is itself awaiting. Which of the two a fill is, is decided where the markup was written and is not something the component consuming it has to know — <slot/> lowers to Slots::render in a synchronous template and to render_async in an awaiting one, and the second handles both.

§Rendering one directly

Render is implemented, so {@render slots.get("footer")} still works — and panics on an awaiting fill, naming the fix, because there is nothing else it could honestly do. Use <slot name="footer"/> instead, which is the form that has an async path. The panic is unreachable from a synchronous template: a fill that awaits makes its whole enclosing template await.

Variants§

§

Ready(&'a (dyn Render + Sync))

Markup that is already there.

§

Awaiting(&'a (dyn AsyncRender + Sync))

Markup that has to suspend to be produced.

Implementations§

Source§

impl<'a> Fill<'a>

Source

pub fn render_async<'r>(self, r: &'r mut dyn Renderer) -> RenderFuture<'r>
where 'a: 'r,

Write this fill into r, suspending if it has to.

Not AsyncRender: that trait has a blanket impl over every Render, which this type is — so an impl here would either conflict with it or, worse, resolve to it and take the panicking synchronous path for exactly the fills that needed the other one.

Trait Implementations§

Source§

impl<'a> Clone for Fill<'a>

Source§

fn clone(&self) -> Fill<'a>

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<'a> Copy for Fill<'a>

Source§

impl Render for Fill<'_>

Source§

fn render_into(&self, r: &mut dyn Renderer)

Write this content into r, with no slots filled.
Source§

fn render_slots(&self, r: &mut dyn Renderer, _slots: Slots<'_>)

Write this content into r, resolving its <slot>s against slots. Read more

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for Fill<'a>

§

impl<'a> Send for Fill<'a>

§

impl<'a> Sync for Fill<'a>

§

impl<'a> Unpin for Fill<'a>

§

impl<'a> UnsafeUnpin for Fill<'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> AsyncRender for T
where T: Render + Sync + ?Sized,

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,

Write this content into r, with no slots filled.
Source§

fn render_slots_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, r: &'life1 mut dyn Renderer, slots: Slots<'life2>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, T: 'async_trait,

Write this content into r, resolving its <slot>s against slots. 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.