pub struct SuspenseContext { /* private fields */ }Expand description
The context with which you can create suspense boundaries for futures.
Implementations§
Source§impl SuspenseContext
impl SuspenseContext
Sourcepub fn suspend<F, Fut, M>(&self, f: F, placeholder: impl Into<Html>) -> Suspense
pub fn suspend<F, Fut, M>(&self, f: F, placeholder: impl Into<Html>) -> Suspense
Suspends async work and streams the result. This function takes a closure that returns a future, allowing the future to spawn more suspensions. The placeholder is sent immediately, while the future output is streamed and replaces the placeholder in the browser.
The future can return any type that implements Into<Html>, including
String, &str, or types like maud::Markup.
Suspended futures must be Send because they are handed to tokio.
Sourcepub async fn cancelled(&self)
pub async fn cancelled(&self)
Yields if SuspendedResponse or the resulting stream type is dropped.
Useful for exiting from suspended futures that should stop if the connection is dropped. Suspended futures are not aborted otherwise, so they will continue to execute if you don’t listen for cancellation.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if SuspendedResponse or the resulting stream type is
dropped.
Useful for exiting from suspended futures that should stop if the connection is dropped. Suspended futures are not aborted otherwise, so they will continue to execute if you don’t listen for cancellation.
Trait Implementations§
Source§impl Clone for SuspenseContext
impl Clone for SuspenseContext
Source§fn clone(&self) -> SuspenseContext
fn clone(&self) -> SuspenseContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more