Skip to content

Commit 46123bf

Browse files
committed
feat(http): expose tls mod and add custom error to allow using other tls implementation
1 parent e1c8c7b commit 46123bf

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

http/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
3737
#![forbid(unsafe_code)]
3838

39-
mod tls;
40-
4139
#[cfg(feature = "runtime")]
4240
mod builder;
4341
#[cfg(feature = "runtime")]
@@ -49,6 +47,7 @@ pub mod body;
4947
pub mod config;
5048
pub mod error;
5149
pub mod http;
50+
pub mod tls;
5251
pub mod util;
5352

5453
#[cfg(feature = "runtime")]

http/src/tls/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub enum TlsError {
1010
Rustls(super::rustls::RustlsError),
1111
#[cfg(feature = "native-tls")]
1212
NativeTls(super::native_tls::NativeTlsError),
13+
OtherTls(Box<dyn error::Error + Send + Sync>),
1314
}
1415

1516
impl fmt::Debug for TlsError {
@@ -22,6 +23,7 @@ impl fmt::Debug for TlsError {
2223
Self::Rustls(ref e) => fmt::Debug::fmt(e, _f),
2324
#[cfg(feature = "native-tls")]
2425
Self::NativeTls(ref e) => fmt::Debug::fmt(e, _f),
26+
Self::OtherTls(ref e) => fmt::Debug::fmt(e, _f),
2527
}
2628
}
2729
}
@@ -36,12 +38,19 @@ impl fmt::Display for TlsError {
3638
Self::Rustls(ref e) => fmt::Debug::fmt(e, _f),
3739
#[cfg(feature = "native-tls")]
3840
Self::NativeTls(ref e) => fmt::Display::fmt(e, _f),
41+
Self::OtherTls(ref e) => fmt::Display::fmt(e, _f),
3942
}
4043
}
4144
}
4245

4346
impl error::Error for TlsError {}
4447

48+
impl From<Box<dyn error::Error + Send + Sync>> for TlsError {
49+
fn from(e: Box<dyn error::Error + Send + Sync>) -> Self {
50+
Self::OtherTls(e)
51+
}
52+
}
53+
4554
impl<S, B> From<TlsError> for HttpServiceError<S, B> {
4655
fn from(e: TlsError) -> Self {
4756
Self::Tls(e)

0 commit comments

Comments
 (0)