pub trait CopilotRequestHandler:
Send
+ Sync
+ 'static {
// Provided methods
fn send_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: CopilotHttpRequest,
_ctx: &'life1 CopilotRequestContext,
) -> Pin<Box<dyn Future<Output = Result<CopilotHttpResponse, CopilotRequestError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn open_websocket<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 CopilotRequestContext,
response: CopilotWebSocketResponse,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn CopilotWebSocketHandler>, CopilotRequestError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
The connection-level Copilot request seam.
One implementor services both transports. Defaults forward transparently to the real upstream, so overriding nothing yields a pass-through; override a method to mutate or replace traffic.
Provided Methods§
Sourcefn send_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: CopilotHttpRequest,
_ctx: &'life1 CopilotRequestContext,
) -> Pin<Box<dyn Future<Output = Result<CopilotHttpResponse, CopilotRequestError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: CopilotHttpRequest,
_ctx: &'life1 CopilotRequestContext,
) -> Pin<Box<dyn Future<Output = Result<CopilotHttpResponse, CopilotRequestError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Service one intercepted HTTP request. Default: forward to the real
upstream via forward_http. Override to mutate the request before
forwarding, mutate the response after, or replace the call entirely.
Sourcefn open_websocket<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 CopilotRequestContext,
response: CopilotWebSocketResponse,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn CopilotWebSocketHandler>, CopilotRequestError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn open_websocket<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 CopilotRequestContext,
response: CopilotWebSocketResponse,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn CopilotWebSocketHandler>, CopilotRequestError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Open a per-connection WebSocket handler. Default: a
CopilotWebSocketForwarder wired to the real upstream.
Override to mutate the handshake (URL / headers via ctx) or return a
custom handler.
Unlike the other SDKs, Rust passes response — the runtime-facing sink
for upstream→runtime messages — as a second argument here rather than
exposing a base-class send_response_message helper. A custom handler
must store this CopilotWebSocketResponse in the returned handler struct
and call CopilotWebSocketResponse::send_message on it to push
upstream messages back to the runtime.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<H: CopilotRequestHandler> CopilotRequestHandler for Arc<H>
Forward through a shared handler, so an Arc<H> can be registered while the
consumer retains a handle (for example to read state the handler records).
impl<H: CopilotRequestHandler> CopilotRequestHandler for Arc<H>
Forward through a shared handler, so an Arc<H> can be registered while the
consumer retains a handle (for example to read state the handler records).