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<StreamingSession, HandlerError>
pub fn new( handler: Arc<WebUIHandler>, protocol: Arc<Protocol>, options: SessionOptions, ) -> Result<StreamingSession, HandlerError>
Create an unstarted owned session.
Sourcepub fn start<'state>(
&mut self,
state: impl Into<StreamingState<'state>>,
) -> Result<StreamStep, HandlerError>
pub fn start<'state>( &mut self, state: impl Into<StreamingState<'state>>, ) -> Result<StreamStep, HandlerError>
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<StreamStep, HandlerError>
pub fn resume<'state>( &mut self, instance_id: BoundaryInstanceId, state: impl Into<StreamingState<'state>>, mode: BoundaryMode, ) -> Result<StreamStep, HandlerError>
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.
Pass an owned Value to move changed subtrees, or a reference to retain
caller ownership. Equal values preserve the prior state-reference base.
Use Self::resume_current when no state changed.
Sourcepub fn resume_current(
&mut self,
instance_id: BoundaryInstanceId,
mode: BoundaryMode,
) -> Result<StreamStep, HandlerError>
pub fn resume_current( &mut self, instance_id: BoundaryInstanceId, mode: BoundaryMode, ) -> Result<StreamStep, HandlerError>
Commit the pending occurrence against the session’s retained state.
The call still returns immediately after the checkpoint flush, preserving
the host’s async pause point before Self::advance, but avoids a state
overlay when no data changed since the preceding step.
Sourcepub fn advance(&mut self) -> Result<StreamStep, HandlerError>
pub fn advance(&mut self) -> Result<StreamStep, HandlerError>
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>, HandlerError>
pub fn update( &mut self, instance_id: BoundaryInstanceId, patch: &Value, ) -> Result<Vec<u8>, HandlerError>
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.
Auto Trait Implementations§
impl !RefUnwindSafe for StreamingSession
impl !Sync for StreamingSession
impl !UnwindSafe for StreamingSession
impl Freeze for StreamingSession
impl Send for StreamingSession
impl Unpin for StreamingSession
impl UnsafeUnpin for StreamingSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more