pub struct BridgeDispatch { /* private fields */ }Expand description
Manages in-flight commands sent to the Chrome extension via native messaging.
Each command gets a UUID, is written to the native messaging stdout, and a oneshot receiver awaits the response from the extension.
Implementations§
Source§impl BridgeDispatch
impl BridgeDispatch
pub fn new(writer: Stdout) -> Self
Sourcepub async fn dispatch(
&self,
tab_id: Option<u32>,
method: &str,
args: Value,
) -> Result<Value, String>
pub async fn dispatch( &self, tab_id: Option<u32>, method: &str, args: Value, ) -> Result<Value, String>
Send a command to the extension and await the response.
§Errors
Returns an error if the write fails, the extension disconnects, or the command times out (30s).
Sourcepub async fn dispatch_cdp(
&self,
tab_id: u32,
domain_method: &str,
params: Option<Value>,
) -> Result<Value, String>
pub async fn dispatch_cdp( &self, tab_id: u32, domain_method: &str, params: Option<Value>, ) -> Result<Value, String>
Send a CDP command to the extension.
§Errors
Returns an error on write failure, disconnect, or timeout.
Sourcepub async fn on_response(
&self,
id: &str,
data: Option<Value>,
error: Option<String>,
)
pub async fn on_response( &self, id: &str, data: Option<Value>, error: Option<String>, )
Called by the native messaging read loop when a response arrives.
Sourcepub async fn cancel_all(&self)
pub async fn cancel_all(&self)
Drop all pending commands (e.g. on disconnect).
pub async fn pending_count(&self) -> usize
Sourcepub async fn pending_ids(&self) -> Vec<String>
pub async fn pending_ids(&self) -> Vec<String>
Return the IDs of all currently pending commands (for testing).
Sourcepub async fn register_test_pending(&self, id: &str) -> Receiver<DispatchResult>
pub async fn register_test_pending(&self, id: &str) -> Receiver<DispatchResult>
Insert a pending command directly and return the receiver (for testing).
Auto Trait Implementations§
impl Freeze for BridgeDispatch
impl !RefUnwindSafe for BridgeDispatch
impl Send for BridgeDispatch
impl Sync for BridgeDispatch
impl Unpin for BridgeDispatch
impl UnsafeUnpin for BridgeDispatch
impl !UnwindSafe for BridgeDispatch
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
Mutably borrows from an owned value. Read more