1111//! To implement a component, implement the `connect_to` method:
1212//!
1313//! ```rust,ignore
14- //! use agent_client_protocol_core::ConnectTo;
15- //! use agent_client_protocol_core::Client;
14+ //! use agent_client_protocol_core::{Agent, Client, Connect, Result};
1615//!
1716//! struct MyAgent {
1817//! // configuration fields
1918//! }
2019//!
2120//! // An agent connects to clients
2221//! impl ConnectTo<Client> for MyAgent {
23- //! async fn connect_to(self, client: impl ConnectTo<Agent>) -> Result<(), agent_client_protocol_core::Error > {
24- //! agent_client_protocol_core:: Agent.builder()
22+ //! async fn connect_to(self, client: impl ConnectTo<Agent>) -> Result<()> {
23+ //! Agent.builder()
2524//! .name("my-agent")
2625//! // configure handlers here
2726//! .connect_to(client)
3332use futures:: future:: BoxFuture ;
3433use std:: { fmt:: Debug , future:: Future , marker:: PhantomData } ;
3534
36- use crate :: { Channel , role:: Role } ;
35+ use crate :: { Channel , Result , role:: Role } ;
3736
3837/// A component that can exchange JSON-RPC messages to an endpoint playing the role `R`
3938/// (e.g., an ACP [`Agent`](`crate::role::acp::Agent`) or an MCP [`Server`](`crate::role::mcp::Server`)).
@@ -69,16 +68,16 @@ use crate::{Channel, role::Role};
6968/// # Implementation Example
7069///
7170/// ```rust,ignore
72- /// use agent_client_protocol_core::{Serve, role::Client};
71+ /// use agent_client_protocol_core::{Agent, Result, Serve, role::Client};
7372///
7473/// struct MyAgent {
7574/// config: AgentConfig,
7675/// }
7776///
7877/// impl Serve<Client> for MyAgent {
79- /// async fn serve(self, client: impl Serve<Client::Counterpart>) -> Result<(), agent_client_protocol_core::Error > {
78+ /// async fn serve(self, client: impl Serve<Client::Counterpart>) -> Result<()> {
8079/// // Set up connection that forwards to client
81- /// agent_client_protocol_core:: Agent.builder()
80+ /// Agent.builder()
8281/// .name("my-agent")
8382/// .on_receive_request(async |req: MyRequest, cx| {
8483/// // Handle request
@@ -124,7 +123,7 @@ pub trait ConnectTo<R: Role>: Send + 'static {
124123 fn connect_to (
125124 self ,
126125 client : impl ConnectTo < R :: Counterpart > ,
127- ) -> impl Future < Output = Result < ( ) , crate :: Error > > + Send ;
126+ ) -> impl Future < Output = Result < ( ) > > + Send ;
128127
129128 /// Convert this component into a channel endpoint and server future.
130129 ///
@@ -141,7 +140,7 @@ pub trait ConnectTo<R: Role>: Send + 'static {
141140 ///
142141 /// A tuple of `(Channel, BoxFuture)` where the channel is for the caller to use
143142 /// and the future must be spawned to run the server.
144- fn into_channel_and_future ( self ) -> ( Channel , BoxFuture < ' static , Result < ( ) , crate :: Error > > )
143+ fn into_channel_and_future ( self ) -> ( Channel , BoxFuture < ' static , Result < ( ) > > )
145144 where
146145 Self : Sized ,
147146 {
@@ -162,11 +161,10 @@ trait ErasedConnectTo<R: Role>: Send {
162161 fn connect_to_erased (
163162 self : Box < Self > ,
164163 client : Box < dyn ErasedConnectTo < R :: Counterpart > > ,
165- ) -> BoxFuture < ' static , Result < ( ) , crate :: Error > > ;
164+ ) -> BoxFuture < ' static , Result < ( ) > > ;
166165
167- fn into_channel_and_future_erased (
168- self : Box < Self > ,
169- ) -> ( Channel , BoxFuture < ' static , Result < ( ) , crate :: Error > > ) ;
166+ fn into_channel_and_future_erased ( self : Box < Self > )
167+ -> ( Channel , BoxFuture < ' static , Result < ( ) > > ) ;
170168}
171169
172170/// Blanket implementation: any `Serve<R>` can be type-erased.
@@ -178,7 +176,7 @@ impl<C: ConnectTo<R>, R: Role> ErasedConnectTo<R> for C {
178176 fn connect_to_erased (
179177 self : Box < Self > ,
180178 client : Box < dyn ErasedConnectTo < R :: Counterpart > > ,
181- ) -> BoxFuture < ' static , Result < ( ) , crate :: Error > > {
179+ ) -> BoxFuture < ' static , Result < ( ) > > {
182180 Box :: pin ( async move {
183181 ( * self )
184182 . connect_to ( DynConnectTo {
@@ -191,7 +189,7 @@ impl<C: ConnectTo<R>, R: Role> ErasedConnectTo<R> for C {
191189
192190 fn into_channel_and_future_erased (
193191 self : Box < Self > ,
194- ) -> ( Channel , BoxFuture < ' static , Result < ( ) , crate :: Error > > ) {
192+ ) -> ( Channel , BoxFuture < ' static , Result < ( ) > > ) {
195193 ( * self ) . into_channel_and_future ( )
196194 }
197195}
@@ -237,13 +235,13 @@ impl<R: Role> DynConnectTo<R> {
237235}
238236
239237impl < R : Role > ConnectTo < R > for DynConnectTo < R > {
240- async fn connect_to ( self , client : impl ConnectTo < R :: Counterpart > ) -> Result < ( ) , crate :: Error > {
238+ async fn connect_to ( self , client : impl ConnectTo < R :: Counterpart > ) -> Result < ( ) > {
241239 self . inner
242240 . connect_to_erased ( Box :: new ( client) as Box < dyn ErasedConnectTo < R :: Counterpart > > )
243241 . await
244242 }
245243
246- fn into_channel_and_future ( self ) -> ( Channel , BoxFuture < ' static , Result < ( ) , crate :: Error > > ) {
244+ fn into_channel_and_future ( self ) -> ( Channel , BoxFuture < ' static , Result < ( ) > > ) {
247245 self . inner . into_channel_and_future_erased ( )
248246 }
249247}
0 commit comments