docs(server): set doc_cfg attributes for tcp feature gated Server methods (#2401)
				
					
				
			This commit is contained in:
		| @@ -52,37 +52,43 @@ impl<I> Server<I, ()> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| #[cfg(feature = "tcp")] | cfg_feature! { | ||||||
| impl Server<AddrIncoming, ()> { |     #![all(feature = "tcp")] | ||||||
|     /// Binds to the provided address, and returns a [`Builder`](Builder). |  | ||||||
|     /// |  | ||||||
|     /// # Panics |  | ||||||
|     /// |  | ||||||
|     /// This method will panic if binding to the address fails. For a method |  | ||||||
|     /// to bind to an address and return a `Result`, see `Server::try_bind`. |  | ||||||
|     pub fn bind(addr: &SocketAddr) -> Builder<AddrIncoming> { |  | ||||||
|         let incoming = AddrIncoming::new(addr).unwrap_or_else(|e| { |  | ||||||
|             panic!("error binding to {}: {}", addr, e); |  | ||||||
|         }); |  | ||||||
|         Server::builder(incoming) |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /// Tries to bind to the provided address, and returns a [`Builder`](Builder). |     impl Server<AddrIncoming, ()> { | ||||||
|     pub fn try_bind(addr: &SocketAddr) -> crate::Result<Builder<AddrIncoming>> { |         /// Binds to the provided address, and returns a [`Builder`](Builder). | ||||||
|         AddrIncoming::new(addr).map(Server::builder) |         /// | ||||||
|     } |         /// # Panics | ||||||
|  |         /// | ||||||
|  |         /// This method will panic if binding to the address fails. For a method | ||||||
|  |         /// to bind to an address and return a `Result`, see `Server::try_bind`. | ||||||
|  |         pub fn bind(addr: &SocketAddr) -> Builder<AddrIncoming> { | ||||||
|  |             let incoming = AddrIncoming::new(addr).unwrap_or_else(|e| { | ||||||
|  |                 panic!("error binding to {}: {}", addr, e); | ||||||
|  |             }); | ||||||
|  |             Server::builder(incoming) | ||||||
|  |         } | ||||||
|  |  | ||||||
|     /// Create a new instance from a `std::net::TcpListener` instance. |         /// Tries to bind to the provided address, and returns a [`Builder`](Builder). | ||||||
|     pub fn from_tcp(listener: StdTcpListener) -> Result<Builder<AddrIncoming>, crate::Error> { |         pub fn try_bind(addr: &SocketAddr) -> crate::Result<Builder<AddrIncoming>> { | ||||||
|         AddrIncoming::from_std(listener).map(Server::builder) |             AddrIncoming::new(addr).map(Server::builder) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// Create a new instance from a `std::net::TcpListener` instance. | ||||||
|  |         pub fn from_tcp(listener: StdTcpListener) -> Result<Builder<AddrIncoming>, crate::Error> { | ||||||
|  |             AddrIncoming::from_std(listener).map(Server::builder) | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| #[cfg(feature = "tcp")] | cfg_feature! { | ||||||
| impl<S, E> Server<AddrIncoming, S, E> { |     #![all(feature = "tcp")] | ||||||
|     /// Returns the local address that this server is bound to. |  | ||||||
|     pub fn local_addr(&self) -> SocketAddr { |     impl<S, E> Server<AddrIncoming, S, E> { | ||||||
|         self.spawn_all.local_addr() |         /// Returns the local address that this server is bound to. | ||||||
|  |         pub fn local_addr(&self) -> SocketAddr { | ||||||
|  |             self.spawn_all.local_addr() | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user