pub struct RunStream<T = RunOutcome> { /* private fields */ }Expand description
A run in progress that yields its events in seq order. Every method
takes &self, so one task may read events while another cancels or
waits in finish. Dropping the last owner cancels the run.
Implementations§
Source§impl<T> RunStream<T>
impl<T> RunStream<T>
Sourcepub async fn next(&self) -> Option<Event>
pub async fn next(&self) -> Option<Event>
Waits for the next event of the run.
Output: the event, or None once the run is over and every
queued event has been read. Safe to call from several tasks.
Sourcepub fn run_id(&self) -> RunId
pub fn run_id(&self) -> RunId
Returns the run id, known before the first event. Store it to resume the run after a cancel or a restart. Output: the id.
Sourcepub fn dropped_deltas(&self) -> u64
pub fn dropped_deltas(&self) -> u64
Returns how many text deltas were dropped because the buffer was
full. The answer in finish is complete either way.
Output: the count.
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Stops the run after the step in flight, also while another task
waits in next or finish. A model call already sent finishes and
is billed and saved first, so resume never sends it again.
Calling it twice, or after the end, is a no-op.
Sourcepub async fn finish(&self) -> Result<T, KitError>
pub async fn finish(&self) -> Result<T, KitError>
Waits for the run to end and returns its result, once. Dropping
this future before the run ends cancels the run, like cancel.
Output: the outcome, the run’s error, Cancelled after a cancel,
or Config on a second call. A panic in the run resumes here.