mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-03 11:41:34 +00:00
swarm/: Make NodeHandlerWrapper an impl detail of connection (#2523)
Previously one would wrap a `ProtocolsHandler` into a `NodeHandlerWrapper` as early as possible, even though the functionality of `NodeHandlerWrapper` is only needed within `mod connection`. This commit makes `NodeHandlerWrapper` an implementation detail of `mod connection`, thus neither `mod protocols_handler`, `mod pool` nor the root level (`libp2p-swarm`) need to bother about the abstraction. In addition to the above, this commit: - Renames `NodeHandlerWrapper` to `HandlerWrapper`. The word `Node` is outdated. - Removes `NodeHandlerWrapperBuilder`. With this simplification it is no longer needed. - Folds `NodeHandlerWrapperError` into `ConnectionError`. No need for upper layers to be aware of the fact that `ProtocolHandler`s are wrapped.
This commit is contained in:
@ -42,7 +42,6 @@ pub mod either;
|
||||
mod map_in;
|
||||
mod map_out;
|
||||
pub mod multi;
|
||||
mod node_handler;
|
||||
mod one_shot;
|
||||
mod select;
|
||||
|
||||
@ -55,10 +54,6 @@ use std::{cmp::Ordering, error, fmt, task::Context, task::Poll, time::Duration};
|
||||
pub use dummy::DummyProtocolsHandler;
|
||||
pub use map_in::MapInEvent;
|
||||
pub use map_out::MapOutEvent;
|
||||
pub use node_handler::{
|
||||
NodeHandlerWrapper, NodeHandlerWrapperBuilder, NodeHandlerWrapperError,
|
||||
NodeHandlerWrapperEvent, NodeHandlerWrapperOutboundOpenInfo,
|
||||
};
|
||||
pub use one_shot::{OneShotHandler, OneShotHandlerConfig};
|
||||
pub use select::{IntoProtocolsHandlerSelect, ProtocolsHandlerSelect};
|
||||
|
||||
@ -222,17 +217,6 @@ pub trait ProtocolsHandler: Send + 'static {
|
||||
{
|
||||
ProtocolsHandlerSelect::new(self, other)
|
||||
}
|
||||
|
||||
/// Creates a builder that allows creating a `NodeHandler` that handles this protocol
|
||||
/// exclusively.
|
||||
///
|
||||
/// > **Note**: This method should not be redefined in a custom `ProtocolsHandler`.
|
||||
fn into_node_handler_builder(self) -> NodeHandlerWrapperBuilder<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
IntoProtocolsHandler::into_node_handler_builder(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration of inbound or outbound substream protocol(s)
|
||||
@ -493,15 +477,6 @@ pub trait IntoProtocolsHandler: Send + 'static {
|
||||
{
|
||||
IntoProtocolsHandlerSelect::new(self, other)
|
||||
}
|
||||
|
||||
/// Creates a builder that will allow creating a `NodeHandler` that handles this protocol
|
||||
/// exclusively.
|
||||
fn into_node_handler_builder(self) -> NodeHandlerWrapperBuilder<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
NodeHandlerWrapperBuilder::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> IntoProtocolsHandler for T
|
||||
|
Reference in New Issue
Block a user