Skip to main content

DomainHandler

Trait DomainHandler 

Source
pub trait DomainHandler: Send + Sync {
    // Required methods
    fn domain_name(&self) -> &'static str;
    fn handle_command(
        &self,
        command: &str,
        params: Value,
        event_sender: &dyn EventSender,
    ) -> Result<Value, CdpError>;

    // Provided methods
    fn on_session_created(&self, _session_id: &str) { ... }
    fn on_session_destroyed(&self, _session_id: &str) { ... }
}
Expand description

CDP Domain handler trait. Each implementation handles one CDP domain (e.g. Page, Runtime, DOM). All browser-specific logic lives here.

Constraints: Send + Sync (cross-thread safe).

Required Methods§

Source

fn domain_name(&self) -> &'static str

Returns the CDP domain name (e.g. “Page”, “Runtime”).

Source

fn handle_command( &self, command: &str, params: Value, event_sender: &dyn EventSender, ) -> Result<Value, CdpError>

Handle a CDP command. command is the full method string (e.g. “Page.navigate”). params is the JSON params object.

Provided Methods§

Source

fn on_session_created(&self, _session_id: &str)

Called when a session enables this domain for the first time.

Source

fn on_session_destroyed(&self, _session_id: &str)

Called when a session is destroyed (while this domain was enabled).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§