Skip to main content

RunStream

Struct RunStream 

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T> Debug for RunStream<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Writes the run id and the dropped delta count. The queued events are not shown. Output: the debug text.

Source§

impl<T> Drop for RunStream<T>

Source§

fn drop(&mut self)

Cancels the run when the stream is dropped, so an unread stream stops calling the model after the step in flight, which is billed; finish guards its own future the same way. A no-op once it ended.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T = RunOutcome> !Freeze for RunStream<T>

§

impl<T = RunOutcome> !RefUnwindSafe for RunStream<T>

§

impl<T> Forget for RunStream<T>

§

impl<T> Move for RunStream<T>

§

impl<T> Send for RunStream<T>
where Arc<Queue>: Send, Arc<CancelState>: Send, Mutex<Option<JoinHandle<Result<T, KitError>>>>: Send,

§

impl<T> Sync for RunStream<T>
where Arc<Queue>: Sync, Arc<CancelState>: Sync, Mutex<Option<JoinHandle<Result<T, KitError>>>>: Sync,

§

impl<T> Unpin for RunStream<T>
where Arc<Queue>: Unpin, Arc<CancelState>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, *const Waiter is !null: Unpin, Align8<usize>: Unpin, JoinHandle<Result<T, KitError>>: Unpin,

§

impl<T> UnsafeUnpin for RunStream<T>
where *const ArcInner<Queue> is !null: UnsafeUnpin, PhantomData<ArcInner<Queue>>: UnsafeUnpin, *const ArcInner<CancelState> is !null: UnsafeUnpin, PhantomData<ArcInner<CancelState>>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const Waiter is !null: UnsafeUnpin, Align8<usize>: UnsafeUnpin, *const Header is !null: UnsafeUnpin, PhantomData<Result<T, KitError>>: UnsafeUnpin,

§

impl<T> UnwindSafe for RunStream<T>
where Arc<Queue>: UnwindSafe, Arc<CancelState>: UnwindSafe, Mutex<Waitlist>: UnwindSafe, AtomicUsize: UnwindSafe, JoinHandle<Result<T, KitError>>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more