pub struct StreamEmitter { /* private fields */ }Expand description
The algebraic effect handler — bridges flow execution to EventBus streaming.
In algebraic effects terms, this is the Handler that captures the evaluation context E[perform(Emit(v))] and translates it to: Handler(v, λx. E[x]) → publish(“flow.stream.{id}”, v) ; resume(x)
Implementations§
Source§impl StreamEmitter
impl StreamEmitter
pub fn new(trace_id: u64, flow_name: &str) -> Self
Sourcepub fn emit(&mut self, step_name: &str, content: &str)
pub fn emit(&mut self, step_name: &str, content: &str)
perform(Emit(content)) — the algebraic effect operation. Pure: records the intent without side effects. The handler (publish_to_bus) materializes it. perform(Emit(content)) — step-level algebraic effect. Epistemic state: “speculate” (unvalidated LLM output).
Sourcepub fn emit_with_context(
&mut self,
step_name: &str,
content: &str,
epistemic_state: &str,
effect_row: &str,
nav_ctx: Option<&NavigationContext>,
)
pub fn emit_with_context( &mut self, step_name: &str, content: &str, epistemic_state: &str, effect_row: &str, nav_ctx: Option<&NavigationContext>, )
perform(Emit(content)) with full epistemic/navigation context.
Emit PIX navigate result — epistemic state “believe” (external source, not yet validated). PIX retrieval: EffectRow = <io, epistemic:believe>
Sourcepub fn emit_mdn_traverse(
&mut self,
step_name: &str,
content: &str,
corpus_ref: &str,
edge_type: &str,
depth: u32,
)
pub fn emit_mdn_traverse( &mut self, step_name: &str, content: &str, corpus_ref: &str, edge_type: &str, depth: u32, )
Emit MDN graph traverse result — epistemic state “believe” with edge type. MDN retrieval: EffectRow = <io, network, epistemic:believe>
Sourcepub fn finalize(&mut self)
pub fn finalize(&mut self)
Mark stream as complete — emit final sentinel. On finalization, if all anchors pass, epistemic state promotes to “know”.
Sourcepub fn finalize_with_epistemic(
&mut self,
epistemic_state: &str,
effect_row: &str,
)
pub fn finalize_with_epistemic( &mut self, epistemic_state: &str, effect_row: &str, )
Finalize with explicit epistemic state (e.g., “believe” if anchors didn’t run).
Sourcepub fn publish_to_bus(&self, bus: &EventBus)
pub fn publish_to_bus(&self, bus: &EventBus)
Materialize: publish all buffered tokens to the EventBus. This is the natural transformation h: F_Σ(B) → M_IO(B).
Sourcepub fn emit_chunks(&mut self, step_name: &str, chunks: &[String])
pub fn emit_chunks(&mut self, step_name: &str, chunks: &[String])
Emit token-level chunks for a step — coinductive stream observations. Each chunk: epistemic_state = “speculate”, effect_row = <io, epistemic:speculate>.
pub fn token_count(&self) -> u64
pub fn tokens(&self) -> &[StreamToken]
Auto Trait Implementations§
impl Freeze for StreamEmitter
impl RefUnwindSafe for StreamEmitter
impl Send for StreamEmitter
impl Sync for StreamEmitter
impl Unpin for StreamEmitter
impl UnsafeUnpin for StreamEmitter
impl UnwindSafe for StreamEmitter
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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