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>
impl<'a> Fill<'a>
Sourcepub fn render_async<'r>(self, r: &'r mut dyn Renderer) -> RenderFuture<'r>where
'a: 'r,
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§
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> 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.