Skip to main content

StreamingResponse

Struct StreamingResponse 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_done(&self) -> bool

Whether the response has emitted its terminal and ended its writer.

Auto Trait Implementations§

§

impl<'a, W> !RefUnwindSafe for StreamingResponse<'a, W>

§

impl<'a, W> !Sync for StreamingResponse<'a, W>

§

impl<'a, W> !UnwindSafe for StreamingResponse<'a, W>

§

impl<'a, W> Freeze for StreamingResponse<'a, W>
where StreamingSink<'a, W>: Freeze, W: ?Sized,

§

impl<'a, W> Send for StreamingResponse<'a, W>
where StreamingSink<'a, W>: Send, W: ?Sized,

§

impl<'a, W> Unpin for StreamingResponse<'a, W>
where StreamingSink<'a, W>: Unpin, W: ?Sized,

§

impl<'a, W> UnsafeUnpin for StreamingResponse<'a, W>
where StreamingSink<'a, W>: UnsafeUnpin, W: ?Sized,

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> 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> 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, 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.