Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve feature documentation #99

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 10 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,10 +42,15 @@ 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(any(feature = "axum", feature = "tungstenite"))]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub mod server_runners;

#[cfg(any(feature = "axum", feature = "tungstenite"))]
pub use server_runners::*;

pub use server::Server;
Expand Down
2 changes: 1 addition & 1 deletion src/server_runners/axum_tungstenite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This module implements an axum-based websockets layer on top of tungstenite, as an alternative to `axum::extract::ws`
//! which does not expose tungstenite types.

#![deny(unreachable_pub, private_in_public)]
#![deny(unreachable_pub)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
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
Loading