Skip to content

Commit

Permalink
add TlsError::into_service_error
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Nov 22, 2021
1 parent 3597af5 commit decf532
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions actix-tls/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Add configurable timeout for accepting TLS connection. [#393]
* Added `TlsError::Timeout` variant. [#393]
* All TLS acceptor services now use `TlsError` for their error types. [#393]
* Added `TlsError::flatten`. [#420]

[#393]: https://github.com/actix/actix-net/pull/393
[#420]: https://github.com/actix/actix-net/pull/420


## 3.0.0-beta.8 - 2021-11-15
Expand Down
18 changes: 16 additions & 2 deletions actix-tls/src/accept/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! TLS acceptor services.

use std::sync::atomic::{AtomicUsize, Ordering};
use std::{
convert::Infallible,
sync::atomic::{AtomicUsize, Ordering},
};

use actix_utils::counter::Counter;

Expand Down Expand Up @@ -36,7 +39,18 @@ pub fn max_concurrent_tls_connect(num: usize) {
/// TLS error combined with service error.
#[derive(Debug)]
pub enum TlsError<TlsErr, SvcErr> {
Tls(TlsErr),
Timeout,
Tls(TlsErr),
Service(SvcErr),
}

impl<TlsErr> TlsError<TlsErr, Infallible> {
/// Casts the infallible service error type returned from acceptors into caller's type.
pub fn into_service_error<SvcErr>(self) -> TlsError<TlsErr, SvcErr> {
match self {
Self::Timeout => TlsError::Timeout,
Self::Tls(err) => TlsError::Tls(err),
Self::Service(_) => unreachable!(),
}
}
}
1 change: 0 additions & 1 deletion actix-tls/src/accept/native_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ impl<T: ActixStream + 'static> ServiceFactory<T> for Acceptor {
type Response = TlsStream<T>;
type Error = TlsError<Error, Infallible>;
type Config = ();

type Service = NativeTlsAcceptorService;
type InitError = ();
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
Expand Down
1 change: 0 additions & 1 deletion actix-tls/src/accept/rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ impl<T: ActixStream> ServiceFactory<T> for Acceptor {
type Response = TlsStream<T>;
type Error = TlsError<io::Error, Infallible>;
type Config = ();

type Service = AcceptorService;
type InitError = ();
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
Expand Down
2 changes: 1 addition & 1 deletion actix-tls/src/connect/tls/rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ where
}

pub enum RustlsConnectorServiceFuture<T, U> {
/// See issue https://github.com/briansmith/webpki/issues/54
/// See issue <https://github.com/briansmith/webpki/issues/54>
InvalidDns,
Future {
connect: Connect<U>,
Expand Down

0 comments on commit decf532

Please sign in to comment.