mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 01:01:34 +00:00
chore: enforce unreachable_pub
lint
The `unreachable_pub` lint makes us aware of uses of `pub` that are not actually reachable from the crate root. This is considered good because it means reading a `pub` somewhere means it is actually public API. Some of our crates are quite large and keeping their entire API surface in your head is difficult. We should strive for most items being `pub(crate)`. This lint helps us enforce that. Pull-Request: #3735.
This commit is contained in:
@ -22,9 +22,9 @@ mod error;
|
||||
|
||||
pub(crate) mod pool;
|
||||
|
||||
pub use error::{
|
||||
ConnectionError, PendingConnectionError, PendingInboundConnectionError,
|
||||
PendingOutboundConnectionError,
|
||||
pub use error::ConnectionError;
|
||||
pub(crate) use error::{
|
||||
PendingConnectionError, PendingInboundConnectionError, PendingOutboundConnectionError,
|
||||
};
|
||||
|
||||
use crate::handler::{
|
||||
@ -85,16 +85,16 @@ impl ConnectionId {
|
||||
|
||||
/// Information about a successfully established connection.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Connected {
|
||||
pub(crate) struct Connected {
|
||||
/// The connected endpoint, including network address information.
|
||||
pub endpoint: ConnectedPoint,
|
||||
pub(crate) endpoint: ConnectedPoint,
|
||||
/// Information obtained from the transport.
|
||||
pub peer_id: PeerId,
|
||||
pub(crate) peer_id: PeerId,
|
||||
}
|
||||
|
||||
/// Event generated by a [`Connection`].
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Event<T> {
|
||||
pub(crate) enum Event<T> {
|
||||
/// Event generated by the [`ConnectionHandler`].
|
||||
Handler(T),
|
||||
/// Address of the remote has changed.
|
||||
@ -102,7 +102,7 @@ pub enum Event<T> {
|
||||
}
|
||||
|
||||
/// A multiplexed connection to a peer with an associated [`ConnectionHandler`].
|
||||
pub struct Connection<THandler>
|
||||
pub(crate) struct Connection<THandler>
|
||||
where
|
||||
THandler: ConnectionHandler,
|
||||
{
|
||||
@ -167,7 +167,7 @@ where
|
||||
{
|
||||
/// Builds a new `Connection` from the given substream multiplexer
|
||||
/// and connection handler.
|
||||
pub fn new(
|
||||
pub(crate) fn new(
|
||||
muxer: StreamMuxerBox,
|
||||
handler: THandler,
|
||||
substream_upgrade_protocol_override: Option<upgrade::Version>,
|
||||
@ -186,19 +186,19 @@ where
|
||||
}
|
||||
|
||||
/// Notifies the connection handler of an event.
|
||||
pub fn on_behaviour_event(&mut self, event: THandler::InEvent) {
|
||||
pub(crate) fn on_behaviour_event(&mut self, event: THandler::InEvent) {
|
||||
self.handler.on_behaviour_event(event);
|
||||
}
|
||||
|
||||
/// Begins an orderly shutdown of the connection, returning the connection
|
||||
/// handler and a `Future` that resolves when connection shutdown is complete.
|
||||
pub fn close(self) -> (THandler, impl Future<Output = io::Result<()>>) {
|
||||
pub(crate) fn close(self) -> (THandler, impl Future<Output = io::Result<()>>) {
|
||||
(self.handler, self.muxing.close())
|
||||
}
|
||||
|
||||
/// Polls the handler and the substream, forwarding events from the former to the latter and
|
||||
/// vice versa.
|
||||
pub fn poll(
|
||||
pub(crate) fn poll(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<Event<THandler::OutEvent>, ConnectionError<THandler::Error>>> {
|
||||
@ -369,16 +369,16 @@ where
|
||||
|
||||
/// Borrowed information about an incoming connection currently being negotiated.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct IncomingInfo<'a> {
|
||||
pub(crate) struct IncomingInfo<'a> {
|
||||
/// Local connection address.
|
||||
pub local_addr: &'a Multiaddr,
|
||||
pub(crate) local_addr: &'a Multiaddr,
|
||||
/// Address used to send back data to the remote.
|
||||
pub send_back_addr: &'a Multiaddr,
|
||||
pub(crate) send_back_addr: &'a Multiaddr,
|
||||
}
|
||||
|
||||
impl<'a> IncomingInfo<'a> {
|
||||
/// Builds the [`ConnectedPoint`] corresponding to the incoming connection.
|
||||
pub fn create_connected_point(&self) -> ConnectedPoint {
|
||||
pub(crate) fn create_connected_point(&self) -> ConnectedPoint {
|
||||
ConnectedPoint::Listener {
|
||||
local_addr: self.local_addr.clone(),
|
||||
send_back_addr: self.send_back_addr.clone(),
|
||||
|
Reference in New Issue
Block a user