mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-01 05:32:19 +00:00
30 lines
798 B
Rust
30 lines
798 B
Rust
|
use protocol::MultistreamSelectError;
|
||
|
use std::io::Error as IoError;
|
||
|
|
||
|
/// Error that can happen when negociating a protocol with the remote.
|
||
|
#[derive(Debug)]
|
||
|
pub enum ProtocolChoiceError {
|
||
|
/// Error in the protocol.
|
||
|
MultistreamSelectError(MultistreamSelectError),
|
||
|
|
||
|
/// Received a message from the remote that makes no sense in the current context.
|
||
|
UnexpectedMessage,
|
||
|
|
||
|
/// We don't support any protocol in common with the remote.
|
||
|
NoProtocolFound,
|
||
|
}
|
||
|
|
||
|
impl From<MultistreamSelectError> for ProtocolChoiceError {
|
||
|
#[inline]
|
||
|
fn from(err: MultistreamSelectError) -> ProtocolChoiceError {
|
||
|
ProtocolChoiceError::MultistreamSelectError(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<IoError> for ProtocolChoiceError {
|
||
|
#[inline]
|
||
|
fn from(err: IoError) -> ProtocolChoiceError {
|
||
|
MultistreamSelectError::from(err).into()
|
||
|
}
|
||
|
}
|