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

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

A connector creates a NetworkStream.

Associated Types

Type of Stream to create

Required Methods

Connect to a remote address.

Implementations on Foreign Types

impl<C, S> NetworkConnector for Pool<C> where
    C: NetworkConnector<Stream = S>,
    S: NetworkStream + Send


impl NetworkConnector for HttpConnector

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

A closure as a connector used to generate TcpStreams per request


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());
    b.connect(&(addr, port))

impl<S, C> NetworkConnector for HttpsConnector<S, C> where
    C: NetworkConnector<Stream = HttpStream>,
    S: SslClient<HttpStream>,