mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-01 18:51:35 +00:00
*: Format with rustfmt (#2188)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
@ -28,16 +28,16 @@ pub(crate) mod pool;
|
||||
|
||||
pub use error::{ConnectionError, PendingConnectionError};
|
||||
pub use handler::{ConnectionHandler, ConnectionHandlerEvent, IntoConnectionHandler};
|
||||
pub use listeners::{ListenerId, ListenersStream, ListenersEvent};
|
||||
pub use listeners::{ListenerId, ListenersEvent, ListenersStream};
|
||||
pub use manager::ConnectionId;
|
||||
pub use substream::{Substream, SubstreamEndpoint, Close};
|
||||
pub use pool::{ConnectionCounters, ConnectionLimits};
|
||||
pub use pool::{EstablishedConnection, EstablishedConnectionIter, PendingConnection};
|
||||
pub use pool::{ConnectionLimits, ConnectionCounters};
|
||||
pub use substream::{Close, Substream, SubstreamEndpoint};
|
||||
|
||||
use crate::muxing::StreamMuxer;
|
||||
use crate::{Multiaddr, PeerId};
|
||||
use std::{error::Error, fmt, pin::Pin, task::Context, task::Poll};
|
||||
use std::hash::Hash;
|
||||
use std::{error::Error, fmt, pin::Pin, task::Context, task::Poll};
|
||||
use substream::{Muxing, SubstreamEvent};
|
||||
|
||||
/// The endpoint roles associated with a peer-to-peer communication channel.
|
||||
@ -55,7 +55,7 @@ impl std::ops::Not for Endpoint {
|
||||
fn not(self) -> Self::Output {
|
||||
match self {
|
||||
Endpoint::Dialer => Endpoint::Listener,
|
||||
Endpoint::Listener => Endpoint::Dialer
|
||||
Endpoint::Listener => Endpoint::Dialer,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ pub enum ConnectedPoint {
|
||||
local_addr: Multiaddr,
|
||||
/// Stack of protocols used to send back data to the remote.
|
||||
send_back_addr: Multiaddr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
impl From<&'_ ConnectedPoint> for Endpoint {
|
||||
@ -106,7 +106,7 @@ impl ConnectedPoint {
|
||||
pub fn to_endpoint(&self) -> Endpoint {
|
||||
match self {
|
||||
ConnectedPoint::Dialer { .. } => Endpoint::Dialer,
|
||||
ConnectedPoint::Listener { .. } => Endpoint::Listener
|
||||
ConnectedPoint::Listener { .. } => Endpoint::Listener,
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ impl ConnectedPoint {
|
||||
pub fn is_dialer(&self) -> bool {
|
||||
match self {
|
||||
ConnectedPoint::Dialer { .. } => true,
|
||||
ConnectedPoint::Listener { .. } => false
|
||||
ConnectedPoint::Listener { .. } => false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ impl ConnectedPoint {
|
||||
pub fn is_listener(&self) -> bool {
|
||||
match self {
|
||||
ConnectedPoint::Dialer { .. } => false,
|
||||
ConnectedPoint::Listener { .. } => true
|
||||
ConnectedPoint::Listener { .. } => true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,9 +237,10 @@ where
|
||||
|
||||
/// Polls the connection for events produced by the associated handler
|
||||
/// as a result of I/O activity on the substream multiplexer.
|
||||
pub fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<Event<THandler::OutEvent>, ConnectionError<THandler::Error>>>
|
||||
{
|
||||
pub fn poll(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<Event<THandler::OutEvent>, ConnectionError<THandler::Error>>> {
|
||||
loop {
|
||||
let mut io_pending = false;
|
||||
|
||||
@ -247,10 +248,13 @@ where
|
||||
// of new substreams.
|
||||
match self.muxing.poll(cx) {
|
||||
Poll::Pending => io_pending = true,
|
||||
Poll::Ready(Ok(SubstreamEvent::InboundSubstream { substream })) => {
|
||||
self.handler.inject_substream(substream, SubstreamEndpoint::Listener)
|
||||
}
|
||||
Poll::Ready(Ok(SubstreamEvent::OutboundSubstream { user_data, substream })) => {
|
||||
Poll::Ready(Ok(SubstreamEvent::InboundSubstream { substream })) => self
|
||||
.handler
|
||||
.inject_substream(substream, SubstreamEndpoint::Listener),
|
||||
Poll::Ready(Ok(SubstreamEvent::OutboundSubstream {
|
||||
user_data,
|
||||
substream,
|
||||
})) => {
|
||||
let endpoint = SubstreamEndpoint::Dialer(user_data);
|
||||
self.handler.inject_substream(substream, endpoint)
|
||||
}
|
||||
@ -265,7 +269,7 @@ where
|
||||
match self.handler.poll(cx) {
|
||||
Poll::Pending => {
|
||||
if io_pending {
|
||||
return Poll::Pending // Nothing to do
|
||||
return Poll::Pending; // Nothing to do
|
||||
}
|
||||
}
|
||||
Poll::Ready(Ok(ConnectionHandlerEvent::OutboundSubstreamRequest(user_data))) => {
|
||||
@ -310,7 +314,7 @@ impl<'a> OutgoingInfo<'a> {
|
||||
/// Builds a `ConnectedPoint` corresponding to the outgoing connection.
|
||||
pub fn to_connected_point(&self) -> ConnectedPoint {
|
||||
ConnectedPoint::Dialer {
|
||||
address: self.address.clone()
|
||||
address: self.address.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user