Connectors
Connector Trait
The core of the monoio-transports crate is its modular and composable connector architecture, which allows developers to easily build complex, high-performance network communication solutions.
At the heart of this design is the Connector trait, which defines a common interface for establishing network connections:
Stacking Connectors
Connectors can be easily composed and stacked to create complex connection setups. For example, let’s say you want to create an HTTPS connector that supports both HTTP/1.1 and HTTP/2 protocol
In this example, we start with a basic TcpConnector, add a TlsConnector on top of it to provide TLS encryption, and then wrap the whole stack with an HttpConnector to handle both HTTP/1.1 and HTTP/2 protocols. This modular approach allows you to easily customize the connector stack to suit your specific needs.
Connector Types
The monoio-transports crate provides several pre-built connector types that you can use as building blocks for your own solutions. Here’s a table outlining the available connectors:
Connector Type | Description |
---|---|
TcpConnector | Establishes TCP connections |
UnixConnector | Establishes Unix domain socket connections |
TlsConnector | Adds TLS encryption to an underlying L4 connector, supporting both native-tls and rustls backends |
HttpConnector | Handles HTTP protocol negotiation and connection setup |
PooledConnector | Provides connection pooling capabilities for any underlying connector |