From 0992071a7f1a36424bcfaf1fbc84541ea041df1a Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 11 Apr 2024 10:19:20 +0200 Subject: add support for tokio & improve net crate api --- net/src/error.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'net/src/error.rs') diff --git a/net/src/error.rs b/net/src/error.rs index 6e04a12..ee93168 100644 --- a/net/src/error.rs +++ b/net/src/error.rs @@ -13,9 +13,18 @@ pub enum Error { #[error("invalid address {0}")] InvalidAddress(String), + #[error("invalid path {0}")] + InvalidPath(String), + #[error("invalid endpoint {0}")] InvalidEndpoint(String), + #[error("Encode error: {0}")] + Encode(String), + + #[error("Decode error: {0}")] + Decode(String), + #[error("Parse endpoint error {0}")] ParseEndpoint(String), @@ -26,23 +35,28 @@ pub enum Error { ChannelSend(String), #[error(transparent)] - ChannelRecv(#[from] smol::channel::RecvError), + ChannelRecv(#[from] async_channel::RecvError), #[error("Ws Error: {0}")] WsError(#[from] async_tungstenite::tungstenite::Error), + #[cfg(feature = "smol")] #[error("Tls Error: {0}")] Rustls(#[from] futures_rustls::rustls::Error), + #[cfg(feature = "tokio")] + #[error("Tls Error: {0}")] + Rustls(#[from] tokio_rustls::rustls::Error), + #[error("Invalid DNS Name: {0}")] - InvalidDnsNameError(#[from] futures_rustls::pki_types::InvalidDnsNameError), + InvalidDnsNameError(#[from] rustls_pki_types::InvalidDnsNameError), #[error(transparent)] - KaryonCore(#[from] karyon_core::error::Error), + KaryonCore(#[from] karyon_core::Error), } -impl From> for Error { - fn from(error: smol::channel::SendError) -> Self { +impl From> for Error { + fn from(error: async_channel::SendError) -> Self { Error::ChannelSend(error.to_string()) } } -- cgit v1.2.3