Skip to content

Commit

Permalink
fix(libp2p): expose builder phase error
Browse files Browse the repository at this point in the history
May close #4829 and #4824.
Export three error types `BehaviourError`, `TransportError`, `WebsocketError` with rename. Feature gated `WebsocketError`.
Exported at crate root as [suggested](#4824 (comment)).

Pull-Request: #5726.
  • Loading branch information
drHuangMHT authored Dec 10, 2024
1 parent 1c3e820 commit 78e6f08
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- Deprecate `void` crate.
See [PR 5676](https://github.com/libp2p/rust-libp2p/pull/5676).

- Expose swarm builder phase errors.
See [PR 5726](https://github.com/libp2p/rust-libp2p/pull/5726).

## 0.54.1

- Update individual crates.
Expand Down
4 changes: 4 additions & 0 deletions libp2p/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ mod phase;
mod select_muxer;
mod select_security;

#[cfg(all(not(target_arch = "wasm32"), feature = "websocket"))]
pub use phase::WebsocketError;
pub use phase::{BehaviourError, TransportError};

/// Build a [`Swarm`](libp2p_swarm::Swarm) by combining an identity, a set of
/// [`Transport`](libp2p_core::Transport)s and a
/// [`NetworkBehaviour`](libp2p_swarm::NetworkBehaviour).
Expand Down
5 changes: 5 additions & 0 deletions libp2p/src/builder/phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ use swarm::*;
use tcp::*;
use websocket::*;

pub use behaviour::BehaviourError;
pub use other_transport::TransportError;
#[cfg(all(not(target_arch = "wasm32"), feature = "websocket"))]
pub use websocket::WebsocketError;

use super::{
select_muxer::SelectMuxerUpgrade, select_security::SelectSecurityUpgrade, SwarmBuilder,
};
Expand Down
7 changes: 6 additions & 1 deletion libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,17 @@ pub mod bandwidth;
#[cfg(doc)]
pub mod tutorials;

#[cfg(all(not(target_arch = "wasm32"), feature = "websocket"))]
pub use builder::WebsocketError as WebsocketBuilderError;
pub use libp2p_identity as identity;
pub use libp2p_identity::PeerId;
pub use libp2p_swarm::{Stream, StreamProtocol};

pub use self::{
builder::SwarmBuilder,
builder::{
BehaviourError as BehaviourBuilderError, SwarmBuilder,
TransportError as TransportBuilderError,
},
core::{
transport::TransportError,
upgrade::{InboundUpgrade, OutboundUpgrade},
Expand Down

0 comments on commit 78e6f08

Please sign in to comment.