pub trait ObserverHandle: Send {
// Required methods
fn recv(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<ProgressEvent, ObserverRecvError>> + Send + '_>>;
fn try_recv(&mut self) -> Result<ProgressEvent, ObserverRecvError>;
fn close(self: Box<Self>);
}Expand description
Handle returned by crate::execution::ExecutionService::observe.
Wraps a tokio::sync::broadcast::Receiver<ProgressEvent> (provided by the engine
layer, Subtask 2). Multiple handles may exist concurrently; each receives the full
event stream independently. When the session’s broadcast sender is dropped (session
terminates), recv() returns Err(ObserverRecvError::Closed).
This is a trait to allow the engine layer (Subtask 2) to provide a concrete
BroadcastObserverHandle struct without a circular dependency on core.
Required Methods§
Sourcefn recv(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<ProgressEvent, ObserverRecvError>> + Send + '_>>
fn recv( &mut self, ) -> Pin<Box<dyn Future<Output = Result<ProgressEvent, ObserverRecvError>> + Send + '_>>
Receive the next event, waiting asynchronously.
Returns Err(ObserverRecvError::Closed) when the broadcast sender is dropped
(session terminated). Returns Err(ObserverRecvError::Lagged(n)) when the
receiver fell behind and n events were skipped; subsequent calls continue
from the latest available event.
Sourcefn try_recv(&mut self) -> Result<ProgressEvent, ObserverRecvError>
fn try_recv(&mut self) -> Result<ProgressEvent, ObserverRecvError>
Non-blocking receive. Returns an event if one is immediately available,
Err(ObserverRecvError::Closed) if the sender is gone, or
Err(ObserverRecvError::Lagged(n)) on a lag event.
Callers should treat Err variants consistently with Self::recv.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".