|
95 | 95 | //! ```
|
96 | 96 | #![doc(html_root_url = "https://docs.rs/native-tls/0.2")]
|
97 | 97 | #![warn(missing_docs)]
|
| 98 | +#![cfg_attr(docsrs, feature(doc_cfg))] |
98 | 99 |
|
99 | 100 | #[macro_use]
|
100 | 101 | #[cfg(any(target_os = "macos", target_os = "ios"))]
|
@@ -328,6 +329,7 @@ pub struct TlsConnectorBuilder {
|
328 | 329 | accept_invalid_hostnames: bool,
|
329 | 330 | use_sni: bool,
|
330 | 331 | disable_built_in_roots: bool,
|
| 332 | + #[cfg(feature = "alpn")] |
331 | 333 | alpn: Vec<String>,
|
332 | 334 | }
|
333 | 335 |
|
@@ -379,8 +381,9 @@ impl TlsConnectorBuilder {
|
379 | 381 |
|
380 | 382 | /// Request specific protocols through ALPN (Application-Layer Protocol Negotiation).
|
381 | 383 | ///
|
382 |
| - /// Defaults to none |
| 384 | + /// Defaults to no protocols. |
383 | 385 | #[cfg(feature = "alpn")]
|
| 386 | + #[cfg_attr(docsrs, doc(cfg(feature = "alpn")))] |
384 | 387 | pub fn request_alpns(&mut self, protocols: &[&str]) -> &mut TlsConnectorBuilder {
|
385 | 388 | self.alpn = protocols.iter().map(|s| (*s).to_owned()).collect();
|
386 | 389 | self
|
@@ -474,6 +477,7 @@ impl TlsConnector {
|
474 | 477 | accept_invalid_certs: false,
|
475 | 478 | accept_invalid_hostnames: false,
|
476 | 479 | disable_built_in_roots: false,
|
| 480 | + #[cfg(feature = "alpn")] |
477 | 481 | alpn: vec![],
|
478 | 482 | }
|
479 | 483 | }
|
@@ -655,8 +659,9 @@ impl<S: io::Read + io::Write> TlsStream<S> {
|
655 | 659 | Ok(self.0.tls_server_end_point()?)
|
656 | 660 | }
|
657 | 661 |
|
658 |
| - /// Returns the negotiated ALPN protocols |
| 662 | + /// Returns the negotiated ALPN protocol. |
659 | 663 | #[cfg(feature = "alpn")]
|
| 664 | + #[cfg_attr(docsrs, doc(cfg(feature = "alpn")))] |
660 | 665 | pub fn negotiated_alpn(&self) -> Result<Option<Vec<u8>>> {
|
661 | 666 | Ok(self.0.negotiated_alpn()?)
|
662 | 667 | }
|
|
0 commit comments