Skip to content

Commit

Permalink
chore(viz): clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 14, 2023
1 parent 33b569e commit 11dfc67
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion viz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,13 @@
))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

#[cfg(any(feature = "http1", feature = "http2"))]
mod responder;
#[cfg(any(feature = "http1", feature = "http2"))]
pub use responder::Responder;

/// TLS
pub mod tls;
pub use responder::Responder;
pub use viz_core::*;
pub use viz_router::*;

Expand Down
6 changes: 4 additions & 2 deletions viz/src/tls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#![allow(clippy::module_name_repetitions)]

mod listener;

pub use listener::Listener;

/// native_tls
/// `native_tls`
#[cfg(feature = "native-tls")]
pub mod native_tls;

/// rustls
/// `rustls`
#[cfg(feature = "rustls")]
pub mod rustls;
17 changes: 13 additions & 4 deletions viz/src/tls/native_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{Error, Result};

pub use tokio_native_tls::{native_tls::Identity, TlsAcceptor};

/// `native-tls`'s config.
/// [`native-tls`]'s config.
pub struct Config {
identity: Identity,
}
Expand All @@ -20,12 +20,17 @@ impl fmt::Debug for Config {
}

impl Config {
/// Creates a new config with the specified [Identity].
/// Creates a new config with the specified [`Identity`].
#[must_use]
pub fn new(identity: Identity) -> Self {
Self { identity }
}

/// Creates a new [TlsAcceptor] wrapper with the specified [Identity].
/// Creates a new [`TlsAcceptor`] wrapper with the specified [`Identity`].
///
/// # Errors
///
/// Will return `Err` if wrapping the identity fails.
pub fn build(self) -> Result<TlsAcceptor> {
TlsAcceptorWrapper::new(self.identity)
.map(Into::into)
Expand All @@ -34,7 +39,11 @@ impl Config {
}

impl Listener<TcpListener, TlsAcceptor> {
/// A [`TlsStream`] and [`SocketAddr] part for accepting TLS.
/// A [`TlsStream`] and [`SocketAddr`] part for accepting TLS.
///
/// # Errors
///
/// Will return `Err` if accepting the stream fails.
pub async fn accept(&self) -> Result<(TlsStream<TcpStream>, SocketAddr)> {
let (stream, addr) = self.inner.accept().await?;
let tls_stream = self.acceptor.accept(stream).await.map_err(Error::normal)?;
Expand Down

0 comments on commit 11dfc67

Please sign in to comment.