pub struct InferenceResultStream { /* private fields */ }Expand description
A streaming view of an incremental distributed inference session.
Results arrive asynchronously via an internal mpsc channel as each peer
responds. The caller polls next_partial to receive one
PartialResult per peer response until the session is complete or the
deadline expires.
§Example
// (obtained from Node::infer_streaming)
let mut stream: InferenceResultStream = todo!();
while let Some(partial) = stream.next_partial().await {
println!("peer {}: {} new bindings", partial.peer_id, partial.new_bindings.len());
if partial.is_final { break; }
}Implementations§
Source§impl InferenceResultStream
impl InferenceResultStream
Sourcepub fn new(
session_id: String,
rx: Receiver<InferenceResponse>,
deadline: Instant,
) -> Self
pub fn new( session_id: String, rx: Receiver<InferenceResponse>, deadline: Instant, ) -> Self
Construct a new stream from a channel receiver and a deadline.
This is used internally by Node::infer_streaming; callers should not
normally construct this directly.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
The session identifier.
Sourcepub fn result_count(&self) -> usize
pub fn result_count(&self) -> usize
Number of binding sets accumulated so far.
Sourcepub async fn next_partial(&mut self) -> Option<PartialResult>
pub async fn next_partial(&mut self) -> Option<PartialResult>
Poll for the next partial result.
Returns None when the deadline has passed or the channel is closed,
indicating that no further results will arrive.
Auto Trait Implementations§
impl Freeze for InferenceResultStream
impl RefUnwindSafe for InferenceResultStream
impl Send for InferenceResultStream
impl Sync for InferenceResultStream
impl Unpin for InferenceResultStream
impl UnsafeUnpin for InferenceResultStream
impl UnwindSafe for InferenceResultStream
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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