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<StreamingSession, HandlerError>

Create an unstarted owned session.

Source

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.

Source

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.

Source

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.

Source

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.