pub struct ClientProtocolConnector { /* private fields */ }unstable_protocol_v2 only.Expand description
Client connector that opens an agent connection with a configured protocol implementation.
Use Client::protocol_connector to start the builder, then add each
supported protocol version independently. Implementations and the agent
connection are provided as factories because fallback from v2 to v1 may
require a fresh connection initialized by the v1 implementation.
The with_v1 and with_v2 slots take any ConnectTo<Agent> factory; nothing checks that an
implementation speaks the slot’s version. Put a .v1() implementation in
with_v1 and a .v2() implementation in with_v2.
Implementations§
Source§impl ClientProtocolConnector
impl ClientProtocolConnector
Sourcepub fn with_v1<C>(self, client: impl FnMut() -> C + Send + 'static) -> Self
pub fn with_v1<C>(self, client: impl FnMut() -> C + Send + 'static) -> Self
Return this connector with an ACP v1 implementation factory configured.
Sourcepub fn with_v2<C>(self, client: impl FnMut() -> C + Send + 'static) -> Self
pub fn with_v2<C>(self, client: impl FnMut() -> C + Send + 'static) -> Self
Return this connector with an ACP v2 implementation factory configured.
Sourcepub async fn connect_to<C>(
self,
agent: impl FnMut() -> C + Send + 'static,
) -> Result<(), Error>
pub async fn connect_to<C>( self, agent: impl FnMut() -> C + Send + 'static, ) -> Result<(), Error>
Connect to an agent produced by agent using the highest configured
compatible protocol implementation.
§Errors
Returns Invalid request (-32600) if no implementation is configured.
Propagates failures while exchanging initialization messages or driving
the selected client and agent connections.