refactor(net): NetworkConnecter no longer is for static usage
Instead, you can use an instance of a NetworkConnector with `Request::with_connector`. This allows overloading of the NetworkStream constructors, so that it is easy to modify how an `HttpStream` is created, while still relying on the rest of the stream implementation. BREAKING CHANGE
This commit is contained in:
@@ -61,14 +61,15 @@ impl Writer for MockStream {
|
||||
}
|
||||
|
||||
impl NetworkStream for MockStream {
|
||||
|
||||
fn peer_name(&mut self) -> IoResult<SocketAddr> {
|
||||
Ok(from_str("127.0.0.1:1337").unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkConnector for MockStream {
|
||||
fn connect<To: ToSocketAddr>(_addr: To, _scheme: &str) -> IoResult<MockStream> {
|
||||
pub struct MockConnector;
|
||||
|
||||
impl NetworkConnector<MockStream> for MockConnector {
|
||||
fn connect<To: ToSocketAddr>(&mut self, _addr: To, _scheme: &str) -> IoResult<MockStream> {
|
||||
Ok(MockStream::new())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user