Skip to content

Commit

Permalink
improve feature documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
UkoeHB committed Jan 7, 2024
1 parent 14d4266 commit 702c85a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ impl<E: ClientExt> Client<E> {
/// - Requires feature `native_client`.
/// - May only be invoked from within a tokio runtime.
#[cfg(feature = "native_client")]
#[cfg_attr(docsrs, doc(cfg(feature = "native_client")))]
pub async fn connect<E: ClientExt + 'static>(
client_fn: impl FnOnce(Client<E>) -> E,
config: ClientConfig,
Expand Down
2 changes: 2 additions & 0 deletions src/client_connectors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cfg_if::cfg_if! {
if #[cfg(all(feature = "native_client", not(target_family = "wasm")))] {
#[cfg_attr(docsrs, doc(cfg(all(feature = "native_client", not(target_family = "wasm")))))]
mod client_connector_tokio;
pub use client_connector_tokio::*;
}
}

cfg_if::cfg_if! {
if #[cfg(all(feature = "wasm_client", target_family = "wasm"))] {
#[cfg_attr(docsrs, doc(cfg(all(feature = "wasm_client", target_family = "wasm"))))]
mod client_connector_wasm;
pub use client_connector_wasm::*;
}
Expand Down
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//!
//! Refer to [`client`] or [`server`] module for detailed implementation guides.
#![cfg_attr(docsrs, feature(doc_cfg))]

mod socket;
mod tungstenite_common;

Expand All @@ -21,7 +23,9 @@ pub use socket::Stream;

cfg_if::cfg_if! {
if #[cfg(feature = "client")] {
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
pub mod client;
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
mod client_connectors;

pub use client_connectors::*;
Expand All @@ -38,9 +42,12 @@ cfg_if::cfg_if! {

cfg_if::cfg_if! {
if #[cfg(feature = "server")] {
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub mod server;
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub mod session;
mod server_runners;
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub mod server_runners;

pub use server_runners::*;

Check failure on line 52 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Lints

unused import: `server_runners::*`

Check warning on line 52 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `server_runners::*`

Expand Down
3 changes: 3 additions & 0 deletions src/server_runners/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
cfg_if::cfg_if! {
if #[cfg(feature = "axum")] {
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
pub mod axum;
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
pub mod axum_tungstenite;
}
}

#[cfg(feature = "tungstenite")]
#[cfg_attr(docsrs, doc(cfg(feature = "tungstenite")))]
pub mod tungstenite;
4 changes: 4 additions & 0 deletions src/server_runners/tungstenite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ use tokio::net::ToSocketAddrs;

pub enum Acceptor {
Plain,

#[cfg(feature = "native-tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))]
NativeTls(tokio_native_tls::TlsAcceptor),

#[cfg(feature = "rustls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
Rustls(tokio_rustls::TlsAcceptor),
}

Expand Down

0 comments on commit 702c85a

Please sign in to comment.