Skip to main content

RegistryDispatch

Trait RegistryDispatch 

Source
pub trait RegistryDispatch:
    Send
    + Sync
    + 'static {
    // Required methods
    fn dispatch_command(
        &self,
        method: &str,
        params: Value,
        event_sender: &dyn EventSender,
    ) -> Option<Result<Value, CdpError>>;
    fn notify_session_created(&self, domain: &str, session_id: &str);
    fn notify_session_destroyed(&self, domains: &[String], session_id: &str);
    fn has_domain(&self, domain: &str) -> bool;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn dispatch_message(
        &self,
        msg: &CdpMessage,
        ws_target_id: &str,
        event_sender: &dyn EventSender,
    ) -> Option<Result<Value, CdpError>> { ... }
}
Expand description

Type-erased dispatch trait. CdpServer holds Arc<dyn RegistryDispatch> so it works with any DomainRegistry<H> regardless of H.

  • Normal message routing: dispatch_command(), has_domain(), etc.
  • Type-safe downcast: as_any()downcast_ref::<DomainRegistry<DomainDispatch>>()

Required Methods§

Source

fn dispatch_command( &self, method: &str, params: Value, event_sender: &dyn EventSender, ) -> Option<Result<Value, CdpError>>

Dispatch a CDP command. Returns None if domain not found.

Source

fn notify_session_created(&self, domain: &str, session_id: &str)

Notify the handler for domain that a session was created.

Source

fn notify_session_destroyed(&self, domains: &[String], session_id: &str)

Notify handlers for the given domains that a session was destroyed.

Source

fn has_domain(&self, domain: &str) -> bool

Check if a domain is registered.

Source

fn as_any(&self) -> &dyn Any

Downcast support — allows callers to recover the concrete registry type.

Provided Methods§

Source

fn dispatch_message( &self, msg: &CdpMessage, ws_target_id: &str, event_sender: &dyn EventSender, ) -> Option<Result<Value, CdpError>>

Dispatch with full routing context: the incoming message (including its optional sessionId for flattened browser sessions) plus the WS session’s own target id (from the /devtools/page/<id> URL, or the browser pseudo-target for /devtools/browser connections).

Default impl discards the context and delegates to dispatch_command; registries that need per-target / per-session routing override this.

Implementations§

Source§

impl dyn RegistryDispatch

Convenience downcast on dyn RegistryDispatch.

Source

pub fn downcast_ref<T: 'static>(&self) -> Option<&T>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<H: DomainHandler + 'static> RegistryDispatch for DomainRegistry<H>

Blanket impl: any DomainRegistry<H> is a RegistryDispatch.