Skip to main content

ChromeBridge

Struct ChromeBridge 

Source
pub struct ChromeBridge { /* private fields */ }
Expand description

The live connection registry. One instance per process (see bridge).

Transport integration (in roder-app-server::remote), on each connection:

// on first `hello` frame:
let reg = bridge().register_client(Some(remote_addr.clone()), &frame);
// spawn a task draining reg.commands -> websocket as Message::Text(JSON)
// for every inbound bridge frame: bridge().ingest_frame(Some(reg.client_id), frame);
// on disconnect: bridge().unregister_client(reg.client_id);

Implementations§

Source§

impl ChromeBridge

Source

pub fn new() -> Self

Source

pub fn register_client( &self, remote_addr: Option<String>, hello: &Value, ) -> ChromeClientRegistration

Register a newly-connected extension. Returns the receiver the transport must drain to deliver commands to that extension.

Source

pub fn unregister_client(&self, client_id: u64)

Remove a disconnected extension and fail any of its pending commands.

Source

pub fn ingest_frame(&self, client_id: Option<u64>, frame: Value)

Route an inbound bridge frame from the extension: resolve a pending command result or fold an unsolicited event into bridge state.

Trait Implementations§

Source§

impl ChromeController for ChromeBridge

Source§

fn status(&self) -> ChromeStatus

Current connection status.
Source§

fn set_enabled(&self, enabled: bool)

Enable/disable Chrome tools for the session.
Source§

fn set_mode(&self, mode: ChromePermissionMode)

Set the permission mode.
Source§

fn dispatch<'life0, 'async_trait>( &'life0 self, command: ChromeCommand, ) -> Pin<Box<dyn Future<Output = Result<Value, ChromeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Forward a command to the connected extension and await its result.
Source§

fn is_enabled(&self) -> bool

Whether Chrome tools are enabled for the session.
Source§

impl Default for ChromeBridge

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.