Skip to main content

StreamingSession

Struct StreamingSession 

Source
pub struct StreamingSession { /* private fields */ }
Expand description

A progressive response owned independently of any Rust borrow.

Exposes the same step machine as super::StreamingResponse: Self::start writes the shell prefix, Self::resume writes exactly one occurrence through its checkpoint, and Self::advance writes the parent bytes that follow it.

Implementations§

Source§

impl StreamingSession

Source

pub fn new( handler: Arc<WebUIHandler>, protocol: Arc<Protocol>, options: SessionOptions, ) -> Result<Self>

Create an unstarted owned session.

Source

pub fn start(&mut self, state: &Value) -> Result<StreamStep>

Render until the first runtime boundary occurrence or terminal.

Source

pub fn resume( &mut self, instance_id: BoundaryInstanceId, state: &Value, mode: BoundaryMode, ) -> Result<StreamStep>

Commit the pending occurrence through its checkpoint, then stop.

The returned bytes hold that occurrence’s record and nothing that follows it. Call Self::advance for the parent bytes.

BoundaryMode::Updatable is refused once the response has committed as many updatable occurrences as the browser retains. The refusal produces no bytes and leaves the occurrence pending, so it can be committed with BoundaryMode::Final instead.

Source

pub fn advance(&mut self) -> Result<StreamStep>

Write the ordinary parent bytes that follow a committed occurrence.

Valid only after Self::resume.

Source

pub fn update( &mut self, instance_id: BoundaryInstanceId, patch: &Value, ) -> Result<Vec<u8>>

Emit an update for one committed updatable runtime occurrence.

Valid between Self::resume and Self::advance, so a host can revise the occurrence it just committed while the response stays open.

Source

pub fn is_done(&self) -> bool

Whether terminal emission completed.

Auto Trait Implementations§

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, <T as TryFrom<U>>::Error>

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.