Skip to main content

ObserverHandle

Trait ObserverHandle 

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

Source

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.

Source

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.

Source

fn close(self: Box<Self>)

Consume and close this handle. After calling close the handle is dropped and no further events can be received.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§