mirror of https://github.com/fafhrd91/actix-net
tweaks
This commit is contained in:
parent
d8134b648c
commit
b26115d7c5
|
@ -3,10 +3,10 @@
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
### Added
|
### Added
|
||||||
* Derive `Debug` for `connect::Connection`. [#422]
|
* Derive `Debug` for `connect::Connection`. [#422]
|
||||||
|
* Implement `Display` for `accept::TlsError`. [#422]
|
||||||
|
* Implement `Error` for `accept::TlsError` where both types also implement `Error`. [#422]
|
||||||
* Implement `Default` for `connect::Resolver`. [#422]
|
* Implement `Default` for `connect::Resolver`. [#422]
|
||||||
* Implement `Display` for `TlsError`. [#422]
|
* Implement `Error` for `connect::ConnectError`. [#422]
|
||||||
* Implement `Error` for `ConnectError`. [#422]
|
|
||||||
* Implement `Error` for `TlsError` where both types also implement `Error`. [#422]
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* There are now no default features. [#422]
|
* There are now no default features. [#422]
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
* Rename struct `connect::{ConnectService => ConnectorService}`. [#422]
|
* Rename struct `connect::{ConnectService => ConnectorService}`. [#422]
|
||||||
* Rename struct `connect::{ConnectServiceFactory => Connector}`. [#422]
|
* Rename struct `connect::{ConnectServiceFactory => Connector}`. [#422]
|
||||||
* Rename TLS acceptor service future types and hide from docs. [#422]
|
* Rename TLS acceptor service future types and hide from docs. [#422]
|
||||||
|
* Unbox some service futures types. [#422]
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
* Remove `connect::{new_connector, new_connector_factory, default_connector, default_connector_factory}` methods. [#422]
|
* Remove `connect::{new_connector, new_connector_factory, default_connector, default_connector_factory}` methods. [#422]
|
||||||
|
|
|
@ -4,10 +4,11 @@ use std::{
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||||
pub(crate) enum ConnectAddrs {
|
pub(crate) enum ConnectAddrs {
|
||||||
None,
|
None,
|
||||||
One(SocketAddr),
|
One(SocketAddr),
|
||||||
|
// TODO: consider using smallvec
|
||||||
Multi(VecDeque<SocketAddr>),
|
Multi(VecDeque<SocketAddr>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,14 @@ pub struct Connection<R, IO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, IO> Connection<R, IO> {
|
impl<R, IO> Connection<R, IO> {
|
||||||
/// Construct new `Connection` from
|
/// Construct new `Connection` from request and IO parts.
|
||||||
pub(crate) fn new(io: IO, req: R) -> Self {
|
pub(crate) fn new(req: R, io: IO) -> Self {
|
||||||
Self { io, req }
|
Self { req, io }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, IO> Connection<R, IO> {
|
impl<R, IO> Connection<R, IO> {
|
||||||
/// Deconstructs into parts.
|
/// Deconstructs into IO and request parts.
|
||||||
pub fn into_parts(self) -> (IO, R) {
|
pub fn into_parts(self) -> (IO, R) {
|
||||||
(self.io, self.req)
|
(self.io, self.req)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ impl<R, IO> Connection<R, IO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Host, IO> Connection<R, IO> {
|
impl<R: Host, IO> Connection<R, IO> {
|
||||||
/// Get hostname.
|
/// Returns hostname.
|
||||||
pub fn hostname(&self) -> &str {
|
pub fn hostname(&self) -> &str {
|
||||||
self.req.hostname()
|
self.req.hostname()
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,12 +148,14 @@ impl<R: Host> Future for TcpConnectorFut<R> {
|
||||||
match ready!(stream.poll(cx)) {
|
match ready!(stream.poll(cx)) {
|
||||||
Ok(sock) => {
|
Ok(sock) => {
|
||||||
let req = req.take().unwrap();
|
let req = req.take().unwrap();
|
||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
"TCP connector: successfully connected to {:?} - {:?}",
|
"TCP connector: successfully connected to {:?} - {:?}",
|
||||||
req.hostname(),
|
req.hostname(),
|
||||||
sock.peer_addr()
|
sock.peer_addr()
|
||||||
);
|
);
|
||||||
return Poll::Ready(Ok(Connection::new(sock, req)));
|
|
||||||
|
return Poll::Ready(Ok(Connection::new(req, sock)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
Loading…
Reference in New Issue