#![allow(clippy::type_complexity)]
#[cfg(feature = "logging")]
use dnet_base::Logging;
use super::map::{Map, Mapping};
pub trait Unwrap {
type Output;
fn unwrap(self) -> Self::Output;
}
pub trait Unwrapping<Incoming, Outgoing, Error>:
dnet_base::Transport<Incoming, Outgoing, Error> + Sized + Unpin
where
Incoming: Unwrap,
Error: std::error::Error,
{
fn unwrapping(
self,
) -> Mapping<
Self,
Incoming,
Outgoing,
fn(Incoming) -> <Incoming as Unwrap>::Output,
fn(Outgoing) -> Outgoing,
Error,
> {
#[allow(unused_mut)]
let mut transport: Mapping<
Self,
Incoming,
Outgoing,
fn(Incoming) -> <Incoming as Unwrap>::Output,
fn(Outgoing) -> Outgoing,
Error,
> = self.unmap(Unwrap::unwrap);
#[cfg(feature = "logging")]
transport.with_logger_mut(|logger| logger.override_kind_with_str("Unwrapping"));
transport
}
}
impl<T, Incoming, Outgoing, Error> Unwrapping<Incoming, Outgoing, Error> for T
where
T: dnet_base::Transport<Incoming, Outgoing, Error> + Unpin,
Incoming: Unwrap,
Error: std::error::Error,
{
}