Skip to main content

ConnectionObserver

Trait ConnectionObserver 

Source
pub trait ConnectionObserver: Send + Sync {
    // Required method
    fn on_event(&self, event: &ClientEvent);

    // Provided method
    fn on_event_owned(&self, event: ClientEvent) { ... }
}
Expand description

Trait for receiving events from a MoQT connection.

Implementations must be Send + Sync because the connection may emit events from async tasks. The on_event method takes &self (not &mut self) – implementations that need mutation should use interior mutability (e.g., Mutex, mpsc::Sender).

The callback is synchronous to keep the hot path simple. Implementations that need async processing should send to an internal channel.

Required Methods§

Source

fn on_event(&self, event: &ClientEvent)

Called when a connection event occurs.

Provided Methods§

Source

fn on_event_owned(&self, event: ClientEvent)

Called with an owned event. Default implementation forwards to on_event(&event). Override to consume the event without cloning – used by the cross-draft dispatch adapter to move the event directly into its AnyClientEvent variant.

Implementors§