ClientConnector

Trait ClientConnector 

Source
pub trait ClientConnector: Clone {
    type Request: Message;
    type Response: Message;

    // Required method
    fn connect(
        self,
    ) -> impl Future<Output = Result<RpcClient<Self::Request, Self::Response>>> + Send + 'static;
}
Expand description

A connection strategy for protosocket rpc clients.

This is called asynchronously by the connection pool to create new connections.

Required Associated Types§

Required Methods§

Source

fn connect( self, ) -> impl Future<Output = Result<RpcClient<Self::Request, Self::Response>>> + Send + 'static

Connect to the server and return a new RpcClient. See crate::client::connect for the typical way to connect. This is called by the ConnectionPool when it needs a new connection.

Your returned future needs to be 'static, and your connector needs to be cheap to clone. One easy way to do that is to just impl ClientConnector on Arc<YourConnectorType> instead of directly on YourConnectorType.

If you have rolling credentials, initialization messages, changing endpoints, or other adaptive connection logic, this is the place to do it or consult those sources of truth.

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.

Implementors§