AcpProxyExt

Trait AcpProxyExt 

Source
pub trait AcpProxyExt<H: JrMessageHandler> {
    // Required methods
    fn on_receive_request_from_successor<R, F>(
        self,
        op: F,
    ) -> JrHandlerChain<ChainedHandler<H, RequestFromSuccessorHandler<R, F>>>
       where R: JrRequest,
             F: AsyncFnMut(R, JrRequestCx<R::Response>) -> Result<(), Error>;
    fn on_receive_notification_from_successor<N, F>(
        self,
        op: F,
    ) -> JrHandlerChain<ChainedHandler<H, NotificationFromSuccessorHandler<N, F>>>
       where N: JrNotification,
             F: AsyncFnMut(N, JrConnectionCx) -> Result<(), Error>;
    fn on_receive_message_from_successor<R, N, F>(
        self,
        op: F,
    ) -> JrHandlerChain<ChainedHandler<H, MessageFromSuccessorHandler<R, N, F>>>
       where R: JrRequest,
             N: JrNotification,
             F: AsyncFnMut(MessageAndCx<R, N>) -> Result<(), Error>;
    fn proxy(self) -> JrHandlerChain<ChainedHandler<H, ProxyHandler>>;
    fn provide_mcp(
        self,
        registry: impl AsRef<McpServiceRegistry>,
    ) -> JrHandlerChain<ChainedHandler<H, McpServiceRegistry>>;
}
Expand description

Extension trait for JrConnection that adds proxy-specific functionality

Required Methods§

Source

fn on_receive_request_from_successor<R, F>( self, op: F, ) -> JrHandlerChain<ChainedHandler<H, RequestFromSuccessorHandler<R, F>>>

Adds a handler for requests received from the successor component.

The provided handler will receive unwrapped ACP messages - the _proxy/successor/receive/* protocol wrappers are handled automatically. Your handler processes normal ACP requests and notifications as if it were a regular ACP component.

§Example
JrConnection::new(tokio::io::stdin(), tokio::io::stdout())
    .on_receive_from_successor(MyHandler)
    .serve()
    .await?;
Source

fn on_receive_notification_from_successor<N, F>( self, op: F, ) -> JrHandlerChain<ChainedHandler<H, NotificationFromSuccessorHandler<N, F>>>

Adds a handler for notifications received from the successor component.

The provided handler will receive unwrapped ACP messages - the _proxy/successor/receive/* protocol wrappers are handled automatically. Your handler processes normal ACP requests and notifications as if it were a regular ACP component.

§Example
JrConnection::new()
    .on_receive_from_successor(MyHandler)
    .serve()
    .await?;
Source

fn on_receive_message_from_successor<R, N, F>( self, op: F, ) -> JrHandlerChain<ChainedHandler<H, MessageFromSuccessorHandler<R, N, F>>>

Adds a handler for messages received from the successor component.

The provided handler will receive unwrapped ACP messages - the _proxy/successor/receive/* protocol wrappers are handled automatically. Your handler processes normal ACP requests and notifications as if it were a regular ACP component.

Source

fn proxy(self) -> JrHandlerChain<ChainedHandler<H, ProxyHandler>>

Installs a proxy layer that proxies all requests/notifications to/from the successor. This is typically the last component in the chain.

Source

fn provide_mcp( self, registry: impl AsRef<McpServiceRegistry>, ) -> JrHandlerChain<ChainedHandler<H, McpServiceRegistry>>

Provide MCP servers to downstream successors. This layer will modify session/new requests to include those MCP servers (unless you intercept them earlier).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<H: JrMessageHandler> AcpProxyExt<H> for JrHandlerChain<H>

Implementors§