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

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

A connector creates a NetworkStream.

Associated Types

type Stream: Into<Box<dyn NetworkStream + 'static + Send, Global>>[src]

Type of Stream to create

Required methods

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

Connect to a remote address.

Implementations on Foreign Types

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

type Stream = PooledStream<S>

pub fn connect(
    &self,
    host: &str,
    port: u16,
    scheme: &str
) -> Result<PooledStream<S>, Error>
[src]

Implementors

impl NetworkConnector for HttpConnector[src]

type Stream = HttpStream

pub fn connect(
    &self,
    host: &str,
    port: u16,
    scheme: &str
) -> Result<HttpStream, Error>
[src]

impl<F> NetworkConnector for F where
    F: Fn(&str, u16, &str) -> Result<TcpStream, Error>, 
[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

pub fn connect(
    &self,
    host: &str,
    port: u16,
    scheme: &str
) -> Result<HttpStream, Error>
[src]

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

type Stream = HttpsStream<<S as SslClient<HttpStream>>::Stream>

pub fn connect(
    &self,
    host: &str,
    port: u16,
    scheme: &str
) -> Result<<HttpsConnector<S, C> as NetworkConnector>::Stream, Error>
[src]