pub struct StreamingResponse<'a, W: FlushWriter + ?Sized> { /* private fields */ }Expand description
A progressive response that writes directly through a FlushWriter.
Steps alternate: Self::start writes the shell prefix and stops before
the first occurrence, Self::resume writes exactly one occurrence through
its checkpoint, and Self::advance writes the ordinary parent bytes that
follow it until the next occurrence or the terminal. Every step is one
independently writable, independently flushed segment.
Implementations§
Source§impl<W: FlushWriter + ?Sized> StreamingResponse<'_, W>
impl<W: FlushWriter + ?Sized> StreamingResponse<'_, W>
Sourcepub fn start<'state>(
&mut self,
state: impl Into<StreamingState<'state>>,
) -> Result<StreamStatus>
pub fn start<'state>( &mut self, state: impl Into<StreamingState<'state>>, ) -> Result<StreamStatus>
Render until the first runtime boundary occurrence or terminal.
Pass an owned Value to move it into the continuation, or a reference
to retain caller ownership and clone only the required projection.
Sourcepub fn resume<'state>(
&mut self,
instance_id: BoundaryInstanceId,
state: impl Into<StreamingState<'state>>,
mode: BoundaryMode,
) -> Result<StreamStatus>
pub fn resume<'state>( &mut self, instance_id: BoundaryInstanceId, state: impl Into<StreamingState<'state>>, mode: BoundaryMode, ) -> Result<StreamStatus>
Commit the pending occurrence through its checkpoint, then stop.
The bytes written by this call are exactly the occurrence’s own record —
no parent or tail bytes follow it — so the host can release the
occurrence the moment it resolves. Call Self::advance next.
BoundaryMode::Updatable is refused once the response has committed
as many updatable occurrences as the browser retains. The refusal is
raised before any byte or state moves, so the same occurrence stays
pending and can be committed with BoundaryMode::Final instead.
Pass an owned Value to move changed subtrees, or a reference to retain
caller ownership. Use Self::resume_current when no state changed.
Sourcepub fn resume_current(
&mut self,
instance_id: BoundaryInstanceId,
mode: BoundaryMode,
) -> Result<StreamStatus>
pub fn resume_current( &mut self, instance_id: BoundaryInstanceId, mode: BoundaryMode, ) -> Result<StreamStatus>
Commit the pending occurrence against the retained state snapshot.
This preserves the checkpoint flush and async pause point while avoiding an overlay when no top-level state changed since the preceding step.
Sourcepub fn advance(&mut self) -> Result<StreamStatus>
pub fn advance(&mut self) -> Result<StreamStatus>
Write the ordinary parent bytes that follow a committed occurrence.
Valid only after Self::resume. Renders the shell until the next
occurrence suspends or the terminal record completes.
Sourcepub fn update(
&mut self,
instance_id: BoundaryInstanceId,
patch: &Value,
) -> Result<()>
pub fn update( &mut self, instance_id: BoundaryInstanceId, patch: &Value, ) -> Result<()>
Emit one projected state update for a committed updatable occurrence.
Valid between Self::resume and Self::advance as well as after
the response has moved on, so a host can revise the occurrence it just
committed while the response is still open.