Add missing fmt::Debug impls (#224)

* Add missing fmt::Debug impls
This commit is contained in:
Nikolay Kim 2023-09-11 21:43:07 +06:00 committed by GitHub
parent 19cc8ab315
commit 02e111d373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 855 additions and 198 deletions

View file

@ -1,5 +1,9 @@
# Changes
## [0.3.1] - 2023-09-11
* Add missing fmt::Debug impls
## [0.3.0] - 2023-06-22
* Release v0.3.0

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-tls"
version = "0.3.0"
version = "0.3.1"
authors = ["ntex contributors <team@ntex.rs>"]
description = "An implementation of SSL streams for ntex backed by OpenSSL"
keywords = ["network", "framework", "async", "futures"]
@ -26,9 +26,9 @@ rustls = ["tls_rust"]
[dependencies]
ntex-bytes = "0.1.19"
ntex-io = "0.3.0"
ntex-util = "0.3.0"
ntex-service = "1.2.0"
ntex-io = "0.3.3"
ntex-util = "0.3.2"
ntex-service = "1.2.6"
log = "0.4"
pin-project-lite = "0.2"

View file

@ -3,12 +3,13 @@ use std::{cell::Cell, rc::Rc, task};
use ntex_util::task::LocalWaker;
#[derive(Clone)]
#[derive(Debug, Clone)]
/// Simple counter with ability to notify task on reaching specific number
///
/// Counter could be cloned, total count is shared across all clones.
pub(super) struct Counter(Rc<CounterInner>);
#[derive(Debug)]
struct CounterInner {
count: Cell<usize>,
capacity: usize,
@ -17,7 +18,7 @@ struct CounterInner {
impl Counter {
/// Create `Counter` instance and set max value.
pub fn new(capacity: usize) -> Self {
pub(super) fn new(capacity: usize) -> Self {
Counter(Rc::new(CounterInner {
capacity,
count: Cell::new(0),
@ -26,13 +27,13 @@ impl Counter {
}
/// Get counter guard.
pub fn get(&self) -> CounterGuard {
pub(super) fn get(&self) -> CounterGuard {
CounterGuard::new(self.0.clone())
}
/// Check if counter is not at capacity. If counter at capacity
/// it registers notification for current task.
pub fn available(&self, cx: &mut task::Context<'_>) -> bool {
pub(super) fn available(&self, cx: &mut task::Context<'_>) -> bool {
self.0.available(cx)
}
}

View file

@ -1,4 +1,6 @@
//! An implementations of SSL streams for ntex ecosystem
#![deny(rust_2018_idioms, unreachable_pub, missing_debug_implementations)]
use std::sync::atomic::{AtomicUsize, Ordering};
#[doc(hidden)]

View file

@ -11,6 +11,7 @@ use crate::MAX_SSL_ACCEPT_COUNTER;
use super::{SslAcceptor as IoSslAcceptor, SslFilter};
#[derive(Debug)]
/// Support `TLS` server connections via openssl package
///
/// `openssl` feature enables `Acceptor` type
@ -71,6 +72,7 @@ impl<F: Filter, C: 'static> ServiceFactory<Io<F>, C> for Acceptor<F> {
}
}
#[derive(Debug)]
/// Support `TLS` server connections via openssl package
///
/// `openssl` feature enables `Acceptor` type

View file

@ -1,6 +1,6 @@
//! An implementation of SSL streams for ntex backed by OpenSSL
use std::cell::{Cell, RefCell};
use std::{any, cmp, error::Error, io, task::Context, task::Poll};
use std::{any, cmp, error::Error, fmt, io, task::Context, task::Poll};
use ntex_bytes::{BufMut, BytesVec};
use ntex_io::{types, Filter, FilterFactory, FilterLayer, Io, Layer, ReadBuf, WriteBuf};
@ -22,11 +22,13 @@ pub struct PeerCert(pub X509);
pub struct PeerCertChain(pub Vec<X509>);
/// An implementation of SSL streams
#[derive(Debug)]
pub struct SslFilter {
inner: RefCell<SslStream<IoInner>>,
handshake: Cell<bool>,
}
#[derive(Debug)]
struct IoInner {
source: Option<BytesVec>,
destination: Option<BytesVec>,
@ -242,6 +244,14 @@ impl Clone for SslAcceptor {
}
}
impl fmt::Debug for SslAcceptor {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SslAcceptor")
.field("timeout", &self.timeout)
.finish()
}
}
impl<F: Filter> FilterFactory<F> for SslAcceptor {
type Filter = SslFilter;
@ -292,6 +302,7 @@ impl<F: Filter> FilterFactory<F> for SslAcceptor {
}
}
#[derive(Debug)]
pub struct SslConnector {
ssl: ssl::Ssl,
}

View file

@ -10,6 +10,7 @@ use ntex_util::{future::Ready, time::Millis};
use super::{TlsAcceptor, TlsFilter};
use crate::{counter::Counter, counter::CounterGuard, MAX_SSL_ACCEPT_COUNTER};
#[derive(Debug)]
/// Support `SSL` connections via rustls package
///
/// `rust-tls` feature enables `RustlsAcceptor` type
@ -71,6 +72,7 @@ impl<F: Filter, C: 'static> ServiceFactory<Io<F>, C> for Acceptor<F> {
}
}
#[derive(Debug)]
/// RusTLS based `Acceptor` service
pub struct AcceptorService<F> {
acceptor: TlsAcceptor,

View file

@ -11,8 +11,9 @@ use crate::rustls::{IoInner, TlsFilter, Wrapper};
use super::{PeerCert, PeerCertChain};
#[derive(Debug)]
/// An implementation of SSL streams
pub struct TlsClientFilter {
pub(crate) struct TlsClientFilter {
inner: IoInner,
session: RefCell<ClientConnection>,
}

View file

@ -25,11 +25,13 @@ pub struct PeerCert(pub Certificate);
#[derive(Debug)]
pub struct PeerCertChain(pub Vec<Certificate>);
#[derive(Debug)]
/// An implementation of SSL streams
pub struct TlsFilter {
inner: InnerTlsFilter,
}
#[derive(Debug)]
enum InnerTlsFilter {
Server(TlsServerFilter),
Client(TlsClientFilter),
@ -110,6 +112,7 @@ impl FilterLayer for TlsFilter {
}
}
#[derive(Debug)]
pub struct TlsAcceptor {
cfg: Arc<ServerConfig>,
timeout: Millis,
@ -162,6 +165,7 @@ impl<F: Filter> FilterFactory<F> for TlsAcceptor {
}
}
#[derive(Debug)]
pub struct TlsConnector {
cfg: Arc<ClientConfig>,
}
@ -189,6 +193,7 @@ impl Clone for TlsConnector {
}
}
#[derive(Debug)]
pub struct TlsConnectorConfigured {
cfg: Arc<ClientConfig>,
server_name: ServerName,
@ -217,6 +222,7 @@ impl<F: Filter> FilterFactory<F> for TlsConnectorConfigured {
}
}
#[derive(Debug)]
pub(crate) struct IoInner {
handshake: Cell<bool>,
}

View file

@ -12,8 +12,9 @@ use crate::Servername;
use super::{PeerCert, PeerCertChain};
#[derive(Debug)]
/// An implementation of SSL streams
pub struct TlsServerFilter {
pub(crate) struct TlsServerFilter {
inner: IoInner,
session: RefCell<ServerConnection>,
}