Skip to main content

ExtensionHandle

Struct ExtensionHandle 

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

Handle used to communicate with powhttp.

Provides methods to register context-menu items, overview fields and connect handlers, as well as querying session data. Cheaply cloneable.

Implementations§

Source§

impl ExtensionHandle

Source

pub async fn shutdown(&self)

Gracefully shuts down the extension runtime.

Source

pub async fn write_text_to_clipboard(&self, text: &str) -> Result<(), Error>

Writes a string to the system clipboard.

Calls clipboard/write_text.

Source

pub async fn extend_context_menu_single<N: Into<ContextMenuNodeSingle>>( &self, node: N, ) -> Result<(), Error>

Adds items to the single-entry context menu.

Accepts anything that converts into a ContextMenuNodeSingle, typically a ContextMenuItemSingle or ContextMenuSubmenuSingle.

Calls context_menu/extend_single.

Source

pub async fn remove_context_menu_item_single( &self, item_id: &str, ) -> Result<(), Error>

Removes a single-entry context-menu item by its item_id.

Calls context_menu/remove_item_single.

Source

pub async fn extend_context_menu_multi<N: Into<ContextMenuNodeMulti>>( &self, node: N, ) -> Result<(), Error>

Adds items to the multi-entry context menu.

Accepts anything that converts into a ContextMenuNodeMulti, typically a ContextMenuItemMulti or ContextMenuSubmenuMulti.

Calls context_menu/extend_multi.

Source

pub async fn remove_context_menu_item_multi( &self, item_id: &str, ) -> Result<(), Error>

Removes a multi-entry context-menu item by its item_id.

Calls context_menu/remove_item_multi.

Source

pub async fn extend_overview<N: Into<OverviewNode>>( &self, node: N, ) -> Result<(), Error>

Adds fields or sections to the Overview section of the Inspector.

Accepts anything that converts into an OverviewNode, typically an OverviewField or OverviewSection.

Calls overview/extend.

Source

pub async fn remove_overview_field(&self, field_id: &str) -> Result<(), Error>

Removes an overview field by its field_id.

Calls overview/remove_field.

Source

pub async fn add_request_tab(&self, tab: MessageTab) -> Result<(), Error>

Adds a tab to the request section of the Inspector.

Calls inspector/add_request_tab.

Source

pub async fn remove_request_tab(&self, tab_id: &str) -> Result<(), Error>

Removes a request tab by its tab_id.

Calls inspector/remove_request_tab.

Source

pub async fn add_response_tab(&self, tab: MessageTab) -> Result<(), Error>

Adds a tab to the response section of the Inspector.

Calls inspector/add_response_tab.

Source

pub async fn remove_response_tab(&self, tab_id: &str) -> Result<(), Error>

Removes a response tab by its tab_id.

Calls inspector/remove_response_tab.

Source

pub async fn add_connect_handler<F, Fut>( &self, handler_id: &str, handler: F, ) -> Result<(), Error>
where F: Fn(ConnectContext, ExtensionHandle) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<ConnectResult, Error>> + Send + 'static,

Registers a handler that is invoked for every new proxy connection.

The handler receives a ConnectContext describing the incoming connection and must return a ConnectResult to accept or reject it.

Calls proxy_server/add_connect_handler.

Source

pub async fn remove_connect_handler( &self, handler_id: &str, ) -> Result<(), Error>

Unregisters a previously added connect handler.

Calls proxy_server/remove_connect_handler.

Source

pub async fn list_sessions(&self) -> Result<Vec<SessionInfo>, Error>

Returns all open sessions.

Calls sessions/list.

Source

pub async fn get_listener_port( &self, session_id: Ulid, ) -> Result<Option<u16>, Error>

Returns the local port the powhttp proxy server is listening on for the given session.

Calls sessions/get_listener_port.

Source

pub async fn get_session_entry_ids( &self, session_id: Ulid, ) -> Result<Option<Vec<Ulid>>, Error>

Returns the entry IDs within a session.

Calls sessions/get_entry_ids.

Source

pub async fn get_session_entry( &self, session_id: Ulid, entry_id: Ulid, ) -> Result<Option<SessionEntry>, Error>

Fetches a full session entry including request, response and timings.

Calls sessions/get_entry.

Source

pub async fn get_request_body_as_text( &self, session_id: Ulid, entry_id: Ulid, ) -> Result<Option<String>, Error>

Returns the request body decoded as a UTF-8 string.

Calls sessions/get_request_body.

Source

pub async fn get_request_body_as_bytes( &self, session_id: Ulid, entry_id: Ulid, ) -> Result<Option<Vec<u8>>, Error>

Returns the request body as raw bytes.

Calls sessions/get_request_body.

Source

pub async fn get_response_body_as_text( &self, session_id: Ulid, entry_id: Ulid, ) -> Result<Option<String>, Error>

Returns the response body decoded as a UTF-8 string.

Calls sessions/get_response_body.

Source

pub async fn get_response_body_as_bytes( &self, session_id: Ulid, entry_id: Ulid, ) -> Result<Option<Vec<u8>>, Error>

Returns the response body as raw bytes.

Calls sessions/get_response_body.

Source

pub async fn get_websocket_messages( &self, session_id: Ulid, entry_id: Ulid, ) -> Result<Option<Vec<WebSocketMessage>>, Error>

Returns all WebSocket messages for a session entry.

Calls sessions/get_websocket_messages.

Source

pub async fn get_tls_connection( &self, connection_id: Ulid, ) -> Result<Option<Vec<TlsEvent>>, Error>

Returns the TLS events for a connection.

Calls tls/get_connection.

Source

pub async fn get_http2_stream_ids( &self, connection_id: Ulid, ) -> Result<Option<Vec<u32>>, Error>

Returns the HTTP/2 stream IDs for a connection.

Calls http2/get_stream_ids.

Source

pub async fn get_http2_stream( &self, connection_id: Ulid, stream_id: u32, ) -> Result<Option<Vec<Http2Event>>, Error>

Returns the HTTP/2 frames for a specific stream.

Calls http2/get_stream.

Trait Implementations§

Source§

impl Clone for ExtensionHandle

Source§

fn clone(&self) -> ExtensionHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V