More precise error passed to inject_dial_upgrade_error (#771)

* More precise error passed to inject_dial_upgrade_error

* Fix concerns

* Fix panic proof
This commit is contained in:
Pierre Krieger
2018-12-18 11:23:13 +01:00
committed by GitHub
parent af698a1ce7
commit 83320e0347
14 changed files with 194 additions and 52 deletions

View File

@ -28,8 +28,6 @@ pub enum UpgradeError<E> {
Select(ProtocolChoiceError),
/// Error during the post-negotiation handshake.
Apply(E),
#[doc(hidden)]
__Nonexhaustive
}
impl<E> UpgradeError<E>
@ -49,7 +47,6 @@ impl<E> UpgradeError<E> {
match self {
UpgradeError::Select(e) => UpgradeError::Select(e),
UpgradeError::Apply(e) => UpgradeError::Apply(f(e)),
UpgradeError::__Nonexhaustive => UpgradeError::__Nonexhaustive
}
}
@ -69,7 +66,6 @@ where
match self {
UpgradeError::Select(e) => write!(f, "select error: {}", e),
UpgradeError::Apply(e) => write!(f, "upgrade apply error: {}", e),
UpgradeError::__Nonexhaustive => f.write_str("__Nonexhaustive")
}
}
}
@ -82,7 +78,6 @@ where
match self {
UpgradeError::Select(e) => Some(e),
UpgradeError::Apply(e) => Some(e),
UpgradeError::__Nonexhaustive => None
}
}
}