pub struct DialogManager { /* private fields */ }Expand description
Manages dialog event handlers for browser automation.
The DialogManager allows registering callbacks that are invoked
whenever a browser dialog (alert, confirm, prompt) is triggered.
It is engine-agnostic: the engine-specific dialog interception
logic calls DialogManager::dispatch when a dialog event occurs.
§Thread Safety
DialogManager is thread-safe and can be shared across async tasks.
§Example
use browser_commander::core::dialog::{DialogEvent, DialogManager};
let mut manager = DialogManager::new();
manager.on_dialog(|event| {
println!("Got dialog: {:?} - {}", event.dialog_type, event.message);
});
// Simulate dispatching a dialog (engine would call this internally)
let event = DialogEvent::from_str_type("alert", "Hello!", None);
manager.dispatch(&event);Implementations§
Source§impl DialogManager
impl DialogManager
Sourcepub fn new_with_engine(engine: EngineType) -> Self
pub fn new_with_engine(engine: EngineType) -> Self
Create a new DialogManager for the given engine.
Sourcepub fn on_dialog<F>(&mut self, handler: F)
pub fn on_dialog<F>(&mut self, handler: F)
Register a dialog handler.
The handler is called synchronously whenever a dialog event is dispatched.
For async handling, dispatch a channel message or use tokio::spawn inside
the handler.
§Arguments
handler- A function that receives aDialogEventreference.
Sourcepub fn clear_dialog_handlers(&mut self)
pub fn clear_dialog_handlers(&mut self)
Remove all registered dialog handlers.
Sourcepub fn handler_count(&self) -> usize
pub fn handler_count(&self) -> usize
Get the number of registered handlers.
Sourcepub fn dispatch(&self, event: &DialogEvent)
pub fn dispatch(&self, event: &DialogEvent)
Dispatch a dialog event to all registered handlers.
This is called by the engine-specific integration when a dialog appears. If no handlers are registered, this is a no-op (the engine integration should auto-dismiss the dialog in that case).
§Arguments
event- The dialog event to dispatch.
Sourcepub fn engine(&self) -> EngineType
pub fn engine(&self) -> EngineType
Get the engine type this manager is associated with.
Trait Implementations§
Source§impl Clone for DialogManager
impl Clone for DialogManager
Source§fn clone(&self) -> DialogManager
fn clone(&self) -> DialogManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DialogManager
impl Debug for DialogManager
Auto Trait Implementations§
impl Freeze for DialogManager
impl RefUnwindSafe for DialogManager
impl Send for DialogManager
impl Sync for DialogManager
impl Unpin for DialogManager
impl UnsafeUnpin for DialogManager
impl UnwindSafe for DialogManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more