Skip to content

Commit 0f4dc51

Browse files
committed
alpn fixes
1 parent 0a68efa commit 0f4dc51

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ description = "A wrapper over a platform's native TLS implementation"
77
repository = "https://github.com/sfackler/rust-native-tls"
88
readme = "README.md"
99

10+
[package.metadata.docs.rs]
11+
features = ["alpn"]
12+
rustdoc-args = ["--cfg", "docsrs"]
13+
1014
[features]
1115
vendored = ["openssl/vendored"]
12-
alpn = ["security-framework/alpn", "openssl/v102"]
16+
alpn = ["security-framework/alpn"]
1317

1418
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
1519
security-framework = "2.0.0"

src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
//! ```
9696
#![doc(html_root_url = "https://docs.rs/native-tls/0.2")]
9797
#![warn(missing_docs)]
98+
#![cfg_attr(docsrs, feature(doc_cfg))]
9899

99100
#[macro_use]
100101
#[cfg(any(target_os = "macos", target_os = "ios"))]
@@ -328,6 +329,7 @@ pub struct TlsConnectorBuilder {
328329
accept_invalid_hostnames: bool,
329330
use_sni: bool,
330331
disable_built_in_roots: bool,
332+
#[cfg(feature = "alpn")]
331333
alpn: Vec<String>,
332334
}
333335

@@ -379,8 +381,9 @@ impl TlsConnectorBuilder {
379381

380382
/// Request specific protocols through ALPN (Application-Layer Protocol Negotiation).
381383
///
382-
/// Defaults to none
384+
/// Defaults to no protocols.
383385
#[cfg(feature = "alpn")]
386+
#[cfg_attr(docsrs, doc(cfg(feature = "alpn")))]
384387
pub fn request_alpns(&mut self, protocols: &[&str]) -> &mut TlsConnectorBuilder {
385388
self.alpn = protocols.iter().map(|s| (*s).to_owned()).collect();
386389
self
@@ -474,6 +477,7 @@ impl TlsConnector {
474477
accept_invalid_certs: false,
475478
accept_invalid_hostnames: false,
476479
disable_built_in_roots: false,
480+
#[cfg(feature = "alpn")]
477481
alpn: vec![],
478482
}
479483
}
@@ -655,8 +659,9 @@ impl<S: io::Read + io::Write> TlsStream<S> {
655659
Ok(self.0.tls_server_end_point()?)
656660
}
657661

658-
/// Returns the negotiated ALPN protocols
662+
/// Returns the negotiated ALPN protocol.
659663
#[cfg(feature = "alpn")]
664+
#[cfg_attr(docsrs, doc(cfg(feature = "alpn")))]
660665
pub fn negotiated_alpn(&self) -> Result<Option<Vec<u8>>> {
661666
Ok(self.0.negotiated_alpn()?)
662667
}

0 commit comments

Comments
 (0)