[][src]Trait hyper::net::NetworkConnector

pub trait NetworkConnector {
type Stream: Into<Box<dyn NetworkStream + Send>>;
    fn connect(
        &self,
        host: &str,
        port: u16,
        scheme: &str
    ) -> Result<Self::Stream>; }

A connector creates a NetworkStream.

Associated Types

type Stream: Into<Box<dyn NetworkStream + Send>>

Type of Stream to create

Loading content...

Required methods

fn connect(&self, host: &str, port: u16, scheme: &str) -> Result<Self::Stream>

Connect to a remote address.

Loading content...

Implementors

impl NetworkConnector for HttpConnector[src]

type Stream = HttpStream

impl<C: NetworkConnector<Stream = S>, S: NetworkStream + Send> NetworkConnector for Pool<C>[src]

type Stream = PooledStream<S>

impl<F> NetworkConnector for F where
    F: Fn(&str, u16, &str) -> Result<TcpStream>, 
[src]

A closure as a connector used to generate TcpStreams per request

Example

Basic example:

Client::with_connector(|addr: &str, port: u16, scheme: &str| {
    TcpStream::connect(&(addr, port))
});

Example using TcpBuilder from the net2 crate if you want to configure your source socket:

Client::with_connector(|addr: &str, port: u16, scheme: &str| {
    let b = try!(TcpBuilder::new_v4());
    try!(b.bind("127.0.0.1:0"));
    b.connect(&(addr, port))
});

type Stream = HttpStream

impl<S: SslClient, C: NetworkConnector<Stream = HttpStream>> NetworkConnector for HttpsConnector<S, C>[src]

type Stream = HttpsStream<S::Stream>

Loading content...