mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-23 14:51:34 +00:00
Change stream ID handling to consider flags. (#436)
Replaces the former odd/even distinction of IDs. However we still increment stream IDs by 2 for backwards compatibility.
This commit is contained in:
committed by
Pierre Krieger
parent
ea1f172397
commit
5c35047ee3
@ -20,10 +20,10 @@
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::future::Future;
|
||||
use std::io::Error as IoError;
|
||||
use std::{io::Error as IoError, ops::Not};
|
||||
|
||||
/// Type of connection for the upgrade.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Endpoint {
|
||||
/// The socket comes from a dialer.
|
||||
Dialer,
|
||||
@ -31,6 +31,18 @@ pub enum Endpoint {
|
||||
Listener,
|
||||
}
|
||||
|
||||
impl Not for Endpoint {
|
||||
type Output = Endpoint;
|
||||
|
||||
fn not(self) -> Self::Output {
|
||||
match self {
|
||||
Endpoint::Dialer => Endpoint::Listener,
|
||||
Endpoint::Listener => Endpoint::Dialer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Implemented on structs that describe a possible upgrade to a connection between two peers.
|
||||
///
|
||||
/// The generic `C` is the type of the incoming connection before it is upgraded.
|
||||
|
Reference in New Issue
Block a user