Add an Error associated type to transports (#835)

* Add an Error associated type to transports

* Improve raw swarm a bit

* Rename map_other to map

* Use source() instead of cause()

* RawSwarmIncErr -> IncomingError
This commit is contained in:
Pierre Krieger
2019-01-10 11:27:06 +01:00
committed by GitHub
parent f55a8bc2f3
commit dbff125df2
30 changed files with 798 additions and 682 deletions

View File

@ -30,15 +30,6 @@ pub enum UpgradeError<E> {
Apply(E),
}
impl<E> UpgradeError<E>
where
E: std::error::Error + Send + Sync + 'static
{
pub fn into_io_error(self) -> std::io::Error {
std::io::Error::new(std::io::ErrorKind::Other, self)
}
}
impl<E> UpgradeError<E> {
pub fn map_err<F, T>(self, f: F) -> UpgradeError<T>
where
@ -72,9 +63,9 @@ where
impl<E> std::error::Error for UpgradeError<E>
where
E: std::error::Error
E: std::error::Error + 'static
{
fn cause(&self) -> Option<&dyn std::error::Error> {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
UpgradeError::Select(e) => Some(e),
UpgradeError::Apply(e) => Some(e),