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
impl ExtensionHandle
Sourcepub async fn write_text_to_clipboard(&self, text: &str) -> Result<(), Error>
pub async fn write_text_to_clipboard(&self, text: &str) -> Result<(), Error>
Writes a string to the system clipboard.
Calls clipboard/write_text.
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.
Removes a single-entry context-menu item by its item_id.
Calls context_menu/remove_item_single.
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.
Removes a multi-entry context-menu item by its item_id.
Calls context_menu/remove_item_multi.
Sourcepub async fn extend_overview<N: Into<OverviewNode>>(
&self,
node: N,
) -> Result<(), Error>
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.
Sourcepub async fn remove_overview_field(&self, field_id: &str) -> Result<(), Error>
pub async fn remove_overview_field(&self, field_id: &str) -> Result<(), Error>
Removes an overview field by its field_id.
Calls overview/remove_field.
Sourcepub async fn add_request_tab(&self, tab: MessageTab) -> Result<(), Error>
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.
Sourcepub async fn remove_request_tab(&self, tab_id: &str) -> Result<(), Error>
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.
Sourcepub async fn add_response_tab(&self, tab: MessageTab) -> Result<(), Error>
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.
Sourcepub async fn remove_response_tab(&self, tab_id: &str) -> Result<(), Error>
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.
Sourcepub 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,
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.
Sourcepub async fn remove_connect_handler(
&self,
handler_id: &str,
) -> Result<(), Error>
pub async fn remove_connect_handler( &self, handler_id: &str, ) -> Result<(), Error>
Unregisters a previously added connect handler.
Calls proxy_server/remove_connect_handler.
Sourcepub async fn list_sessions(&self) -> Result<Vec<SessionInfo>, Error>
pub async fn list_sessions(&self) -> Result<Vec<SessionInfo>, Error>
Returns all open sessions.
Calls sessions/list.
Sourcepub async fn get_listener_port(
&self,
session_id: Ulid,
) -> Result<Option<u16>, Error>
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.
Sourcepub async fn get_session_entry_ids(
&self,
session_id: Ulid,
) -> Result<Option<Vec<Ulid>>, Error>
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.
Sourcepub async fn get_session_entry(
&self,
session_id: Ulid,
entry_id: Ulid,
) -> Result<Option<SessionEntry>, Error>
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.
Sourcepub async fn get_request_body_as_text(
&self,
session_id: Ulid,
entry_id: Ulid,
) -> Result<Option<String>, Error>
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.
Sourcepub async fn get_request_body_as_bytes(
&self,
session_id: Ulid,
entry_id: Ulid,
) -> Result<Option<Vec<u8>>, Error>
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.
Sourcepub async fn get_response_body_as_text(
&self,
session_id: Ulid,
entry_id: Ulid,
) -> Result<Option<String>, Error>
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.
Sourcepub async fn get_response_body_as_bytes(
&self,
session_id: Ulid,
entry_id: Ulid,
) -> Result<Option<Vec<u8>>, Error>
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.
Sourcepub async fn get_websocket_messages(
&self,
session_id: Ulid,
entry_id: Ulid,
) -> Result<Option<Vec<WebSocketMessage>>, Error>
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.
Sourcepub async fn get_tls_connection(
&self,
connection_id: Ulid,
) -> Result<Option<Vec<TlsEvent>>, Error>
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.
Sourcepub async fn get_http2_stream_ids(
&self,
connection_id: Ulid,
) -> Result<Option<Vec<u32>>, Error>
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.
Sourcepub async fn get_http2_stream(
&self,
connection_id: Ulid,
stream_id: u32,
) -> Result<Option<Vec<Http2Event>>, Error>
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
impl Clone for ExtensionHandle
Source§fn clone(&self) -> ExtensionHandle
fn clone(&self) -> ExtensionHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more