mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-24 07:11:38 +00:00
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:
@ -51,6 +51,7 @@ use crate::{
|
||||
},
|
||||
protocols_handler::{NodeHandlerWrapper, ProtocolsHandler},
|
||||
topology::Topology,
|
||||
transport::TransportError,
|
||||
topology::DisconnectReason,
|
||||
};
|
||||
use futures::prelude::*;
|
||||
@ -115,6 +116,7 @@ where TBehaviour: NetworkBehaviour<TTopology>,
|
||||
<TMuxer as StreamMuxer>::OutboundSubstream: Send + 'static,
|
||||
<TMuxer as StreamMuxer>::Substream: Send + 'static,
|
||||
TTransport: Transport<Output = (PeerId, TMuxer)> + Clone,
|
||||
TTransport::Error: Send + 'static,
|
||||
TTransport::Listener: Send + 'static,
|
||||
TTransport::ListenerUpgrade: Send + 'static,
|
||||
TTransport::Dial: Send + 'static,
|
||||
@ -171,7 +173,7 @@ where TBehaviour: NetworkBehaviour<TTopology>,
|
||||
/// Returns an error if the address is not supported.
|
||||
/// On success, returns an alternative version of the address.
|
||||
#[inline]
|
||||
pub fn listen_on(me: &mut Self, addr: Multiaddr) -> Result<Multiaddr, Multiaddr> {
|
||||
pub fn listen_on(me: &mut Self, addr: Multiaddr) -> Result<Multiaddr, TransportError<TTransport::Error>> {
|
||||
let result = me.raw_swarm.listen_on(addr);
|
||||
if let Ok(ref addr) = result {
|
||||
me.listened_addrs.push(addr.clone());
|
||||
@ -183,7 +185,7 @@ where TBehaviour: NetworkBehaviour<TTopology>,
|
||||
///
|
||||
/// Returns an error if the address is not supported.
|
||||
#[inline]
|
||||
pub fn dial_addr(me: &mut Self, addr: Multiaddr) -> Result<(), Multiaddr> {
|
||||
pub fn dial_addr(me: &mut Self, addr: Multiaddr) -> Result<(), TransportError<TTransport::Error>> {
|
||||
let handler = me.behaviour.new_handler();
|
||||
me.raw_swarm.dial(addr, handler.into_node_handler())
|
||||
}
|
||||
@ -232,6 +234,7 @@ where TBehaviour: NetworkBehaviour<TTopology>,
|
||||
<TMuxer as StreamMuxer>::OutboundSubstream: Send + 'static,
|
||||
<TMuxer as StreamMuxer>::Substream: Send + 'static,
|
||||
TTransport: Transport<Output = (PeerId, TMuxer)> + Clone,
|
||||
TTransport::Error: Send + 'static,
|
||||
TTransport::Listener: Send + 'static,
|
||||
TTransport::ListenerUpgrade: Send + 'static,
|
||||
TTransport::Dial: Send + 'static,
|
||||
|
Reference in New Issue
Block a user