Trait TcpStreamConnectorFactory
pub trait TcpStreamConnectorFactory<State>:
Send
+ Sync
+ 'static {
type Connector: TcpStreamConnector;
type Error;
// Required method
fn make_connector(
&self,
ctx: Context<State>,
) -> impl Future<Output = Result<CreatedTcpStreamConnector<State, Self::Connector>, Self::Error>> + Send;
}
Expand description
Factory to create a TcpStreamConnector
. This is used by the TCP
stream service to create a stream within a specific Context
.
In the most simplest case you use a TcpStreamConnectorCloneFactory
to use a Clone
able TcpStreamConnectorCloneFactory
, but in more
advanced cases you can use variants of TcpStreamConnector
specific
to the given contexts.
Examples why you might variants:
- you might have specific needs for your sockets (e.g. bind to a specific interface)
that you do not have for all your egress traffic. A crate such as [
socket2
] can help you with this; - it is possible that you have specific filter or firewall needs for some of your egress traffic but not all of it.
Required Associated Types§
type Connector: TcpStreamConnector
type Connector: TcpStreamConnector
TcpStreamConnector
created by this TcpStreamConnectorFactory
type Error
type Error
Error returned in case TcpStreamConnectorFactory
was
not able to create a TcpStreamConnector
.
Required Methods§
fn make_connector(
&self,
ctx: Context<State>,
) -> impl Future<Output = Result<CreatedTcpStreamConnector<State, Self::Connector>, Self::Error>> + Send
fn make_connector( &self, ctx: Context<State>, ) -> impl Future<Output = Result<CreatedTcpStreamConnector<State, Self::Connector>, Self::Error>> + Send
Try to create a TcpStreamConnector
, and return an error or otherwise.
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.