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
impl StreamingSession
Sourcepub fn new(
handler: Arc<WebUIHandler>,
protocol: Arc<Protocol>,
options: SessionOptions,
) -> Result<Self>
pub fn new( handler: Arc<WebUIHandler>, protocol: Arc<Protocol>, options: SessionOptions, ) -> Result<Self>
Create an unstarted owned session.
Sourcepub fn start(&mut self, state: &Value) -> Result<StreamStep>
pub fn start(&mut self, state: &Value) -> Result<StreamStep>
Render until the first runtime boundary occurrence or terminal.
Sourcepub fn resume(
&mut self,
instance_id: BoundaryInstanceId,
state: &Value,
mode: BoundaryMode,
) -> Result<StreamStep>
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.
Sourcepub fn advance(&mut self) -> Result<StreamStep>
pub fn advance(&mut self) -> Result<StreamStep>
Write the ordinary parent bytes that follow a committed occurrence.
Valid only after Self::resume.
Sourcepub fn update(
&mut self,
instance_id: BoundaryInstanceId,
patch: &Value,
) -> Result<Vec<u8>>
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.