Skip to main content

StreamingSession

Struct StreamingSession 

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

A progressive HTML response a foreign host drives one call at a time.

Every method returns the bytes that call produced. The host writes them to its transport and decides when to continue, so backpressure and interleaved async work stay under host control.

Ordering rules match StreamingResponse: the shell first, then each boundary exactly once in declaration order, updates only after the target boundary commits, and finish last. Violations return an actionable error rather than corrupting the stream, and any render or transport failure permanently poisons the session because bytes may already have been sent.

Implementations§

Source§

impl StreamingSession

Source

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

Start a host-driven progressive response.

§Errors

Returns an error when the entry is missing or its compiled streaming structure is malformed.

Source

pub fn boundary(&self, name: &str) -> Result<BoundaryId>

Resolve a free-form authored boundary name to an integer handle.

Resolve once and reuse the handle; hot calls never hash a name.

§Errors

Returns an actionable error listing valid names when the entry does not declare name.

Source

pub fn boundary_count(&self) -> usize

Number of compile-time boundaries in this entry.

Source

pub fn is_finished(&self) -> bool

Whether the response has emitted its terminal record.

Stays false after a rejected or failed finish, because no terminal record reached the transport in either case.

Source

pub fn write_shell(&mut self, state: &Value) -> Result<Vec<u8>>

Render the document prefix before the first boundary.

§Errors

Returns an error when called out of order or when rendering fails.

Source

pub fn write_boundary( &mut self, boundary: BoundaryId, state: &Value, mode: BoundaryMode, ) -> Result<Vec<u8>>

Render and commit the next compile-time boundary.

§Errors

Returns an error when boundaries are written out of declaration order or when rendering fails.

Source

pub fn update(&mut self, boundary: BoundaryId, state: &Value) -> Result<Vec<u8>>

Push a projected state patch to an already committed updatable boundary.

§Errors

Returns an error when the boundary has not committed, was committed as final, or when state is not a JSON object.

Source

pub fn finish(&mut self, state: &Value) -> Result<Vec<u8>>

Render the document tail and emit the terminal record.

The session is finished afterwards and every later call fails.

§Errors

Returns an error when boundaries remain uncommitted or rendering fails.

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 = Infallible

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.