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
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>
Start a host-driven progressive response.
§Errors
Returns an error when the entry is missing or its compiled streaming structure is malformed.
Sourcepub fn boundary(&self, name: &str) -> Result<BoundaryId>
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.
Sourcepub fn boundary_count(&self) -> usize
pub fn boundary_count(&self) -> usize
Number of compile-time boundaries in this entry.
Sourcepub fn is_finished(&self) -> bool
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.
Sourcepub fn write_shell(&mut self, state: &Value) -> Result<Vec<u8>>
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.
Sourcepub fn write_boundary(
&mut self,
boundary: BoundaryId,
state: &Value,
mode: BoundaryMode,
) -> Result<Vec<u8>>
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.