mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
feat(swarm): make stream uprade errors more ergonomic
The currently provided `ConnectionHandlerUpgrErr` is very hard to use. Not only does it have a long name, it also features 3 levels of nesting which results in a lot of boilerplate. Last but not least, it exposes `multistream-select` as a dependency to all protocols. We fix all of the above by renaming the type to `StreamUpgradeError` and flattening out its interface. Unrecoverable errors during protocol selection are hidden within the `Io` variant. Related: #3759. Pull-Request: #3882.
This commit is contained in:
@ -28,8 +28,8 @@ use std::{
|
||||
use libp2p_core::Multiaddr;
|
||||
use libp2p_identity::PeerId;
|
||||
use libp2p_swarm::{
|
||||
derive_prelude::ConnectionEstablished, ConnectionClosed, ConnectionHandlerUpgrErr,
|
||||
ConnectionId, FromSwarm, NetworkBehaviour, NotifyHandler, PollParameters, THandlerInEvent,
|
||||
derive_prelude::ConnectionEstablished, ConnectionClosed, ConnectionId, FromSwarm,
|
||||
NetworkBehaviour, NotifyHandler, PollParameters, StreamUpgradeError, THandlerInEvent,
|
||||
THandlerOutEvent, ToSwarm,
|
||||
};
|
||||
use void::Void;
|
||||
@ -41,7 +41,7 @@ use super::{RunId, RunParams, RunStats};
|
||||
#[derive(Debug)]
|
||||
pub struct Event {
|
||||
pub id: RunId,
|
||||
pub result: Result<RunStats, ConnectionHandlerUpgrErr<Void>>,
|
||||
pub result: Result<RunStats, StreamUpgradeError<Void>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -31,7 +31,7 @@ use libp2p_swarm::{
|
||||
ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound,
|
||||
ListenUpgradeError,
|
||||
},
|
||||
ConnectionHandler, ConnectionHandlerEvent, ConnectionHandlerUpgrErr, KeepAlive, StreamProtocol,
|
||||
ConnectionHandler, ConnectionHandlerEvent, KeepAlive, StreamProtocol, StreamUpgradeError,
|
||||
SubstreamProtocol,
|
||||
};
|
||||
use void::Void;
|
||||
@ -47,7 +47,7 @@ pub struct Command {
|
||||
#[derive(Debug)]
|
||||
pub struct Event {
|
||||
pub(crate) id: RunId,
|
||||
pub(crate) result: Result<RunStats, ConnectionHandlerUpgrErr<Void>>,
|
||||
pub(crate) result: Result<RunStats, StreamUpgradeError<Void>>,
|
||||
}
|
||||
|
||||
pub struct Handler {
|
||||
|
Reference in New Issue
Block a user