mirror of https://github.com/fafhrd91/actix-net
				
				
				
			internal rename
This commit is contained in:
		
							parent
							
								
									a0e04c797b
								
							
						
					
					
						commit
						375597ad90
					
				|  | @ -13,12 +13,12 @@ pub(crate) enum ConnectAddrs { | |||
| } | ||||
| 
 | ||||
| impl ConnectAddrs { | ||||
|     pub(crate) fn is_none(&self) -> bool { | ||||
|     pub(crate) fn is_unresolved(&self) -> bool { | ||||
|         matches!(self, Self::None) | ||||
|     } | ||||
| 
 | ||||
|     pub(crate) fn is_some(&self) -> bool { | ||||
|         !self.is_none() | ||||
|     pub(crate) fn is_resolved(&self) -> bool { | ||||
|         !self.is_unresolved() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -80,8 +80,8 @@ impl<R: Host> ConnectInfo<R> { | |||
| 
 | ||||
|     /// Set local address to connection with.
 | ||||
|     ///
 | ||||
|     /// Useful in situations where you know the IP address bound to a particular network interface
 | ||||
|     /// and want to make sure the socket is opened through that interface.
 | ||||
|     /// Useful in situations where the IP address bound to a particular network interface is known.
 | ||||
|     /// This would make sure the socket is opened through that interface.
 | ||||
|     pub fn set_local_addr(mut self, addr: impl Into<IpAddr>) -> Self { | ||||
|         self.local_addr = Some(addr.into()); | ||||
|         self | ||||
|  |  | |||
|  | @ -101,12 +101,14 @@ impl<R: Host> Service<ConnectInfo<R>> for ResolverService { | |||
|     actix_service::always_ready!(); | ||||
| 
 | ||||
|     fn call(&self, req: ConnectInfo<R>) -> Self::Future { | ||||
|         if req.addr.is_some() { | ||||
|             ResolverFut::Connected(Some(req)) | ||||
|         if req.addr.is_resolved() { | ||||
|             // socket address(es) already resolved; return existing connection request
 | ||||
|             ResolverFut::Resolved(Some(req)) | ||||
|         } else if let Ok(ip) = req.hostname().parse() { | ||||
|             // request hostname is valid ip address; add address to request and return
 | ||||
|             let addr = SocketAddr::new(ip, req.port()); | ||||
|             let req = req.set_addr(Some(addr)); | ||||
|             ResolverFut::Connected(Some(req)) | ||||
|             ResolverFut::Resolved(Some(req)) | ||||
|         } else { | ||||
|             trace!("DNS resolver: resolving host {:?}", req.hostname()); | ||||
| 
 | ||||
|  | @ -127,7 +129,7 @@ impl<R: Host> Service<ConnectInfo<R>> for ResolverService { | |||
| 
 | ||||
|                         let req = req.set_addrs(addrs); | ||||
| 
 | ||||
|                         if req.addr.is_none() { | ||||
|                         if req.addr.is_unresolved() { | ||||
|                             Err(ConnectError::NoRecords) | ||||
|                         } else { | ||||
|                             Ok(req) | ||||
|  | @ -140,8 +142,9 @@ impl<R: Host> Service<ConnectInfo<R>> for ResolverService { | |||
| } | ||||
| 
 | ||||
| /// Future for resolver service.
 | ||||
| #[doc(hidden)] | ||||
| pub enum ResolverFut<R: Host> { | ||||
|     Connected(Option<ConnectInfo<R>>), | ||||
|     Resolved(Option<ConnectInfo<R>>), | ||||
|     LookUp( | ||||
|         JoinHandle<io::Result<IntoIter<SocketAddr>>>, | ||||
|         Option<ConnectInfo<R>>, | ||||
|  | @ -154,7 +157,7 @@ impl<R: Host> Future for ResolverFut<R> { | |||
| 
 | ||||
|     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||||
|         match self.get_mut() { | ||||
|             Self::Connected(conn) => Poll::Ready(Ok(conn | ||||
|             Self::Resolved(conn) => Poll::Ready(Ok(conn | ||||
|                 .take() | ||||
|                 .expect("ResolverFuture polled after finished"))), | ||||
| 
 | ||||
|  | @ -185,7 +188,7 @@ impl<R: Host> Future for ResolverFut<R> { | |||
|                     req.addrs() | ||||
|                 ); | ||||
| 
 | ||||
|                 if req.addr.is_none() { | ||||
|                 if req.addr.is_unresolved() { | ||||
|                     Poll::Ready(Err(ConnectError::NoRecords)) | ||||
|                 } else { | ||||
|                     Poll::Ready(Ok(req)) | ||||
|  |  | |||
|  | @ -90,7 +90,7 @@ impl<R: Host> TcpConnectorFut<R> { | |||
|         local_addr: Option<IpAddr>, | ||||
|         addr: ConnectAddrs, | ||||
|     ) -> TcpConnectorFut<R> { | ||||
|         if addr.is_none() { | ||||
|         if addr.is_unresolved() { | ||||
|             error!("TCP connector: unresolved connection address"); | ||||
|             return TcpConnectorFut::Error(Some(ConnectError::Unresolved)); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue