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:
Thomas Eizinger
2023-04-26 09:31:56 +02:00
committed by GitHub
parent e5dbeb3e08
commit 135942d319
93 changed files with 861 additions and 767 deletions

View File

@ -23,12 +23,12 @@ use prometheus_client::metrics::counter::Counter;
use prometheus_client::metrics::family::Family;
use prometheus_client::registry::Registry;
pub struct Metrics {
pub(crate) struct Metrics {
events: Family<EventLabels, Counter>,
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("dcutr");
let events = Family::default();

View File

@ -21,12 +21,12 @@
use prometheus_client::metrics::counter::Counter;
use prometheus_client::registry::Registry;
pub struct Metrics {
pub(crate) struct Metrics {
messages: Counter,
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("gossipsub");
let messages = Counter::default();

View File

@ -30,7 +30,7 @@ use std::collections::HashMap;
use std::iter;
use std::sync::{Arc, Mutex};
pub struct Metrics {
pub(crate) struct Metrics {
protocols: Protocols,
error: Counter,
pushed: Counter,
@ -42,7 +42,7 @@ pub struct Metrics {
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("identify");
let protocols = Protocols::default();

View File

@ -24,7 +24,7 @@ use prometheus_client::metrics::family::Family;
use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
use prometheus_client::registry::{Registry, Unit};
pub struct Metrics {
pub(crate) struct Metrics {
query_result_get_record_ok: Counter,
query_result_get_record_error: Family<GetRecordResult, Counter>,
@ -45,7 +45,7 @@ pub struct Metrics {
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("kad");
let query_result_get_record_ok = Counter::default();

View File

@ -52,14 +52,14 @@ enum Failure {
Other,
}
pub struct Metrics {
pub(crate) struct Metrics {
rtt: Histogram,
failure: Family<FailureLabels, Counter>,
pong_received: Counter,
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("ping");
let rtt = Histogram::new(exponential_buckets(0.001, 2.0, 12));

View File

@ -1,6 +1,6 @@
use libp2p_core::multiaddr::Multiaddr;
pub fn as_string(ma: &Multiaddr) -> String {
pub(crate) fn as_string(ma: &Multiaddr) -> String {
let len = ma
.protocol_stack()
.fold(0, |acc, proto| acc + proto.len() + 1);

View File

@ -23,12 +23,12 @@ use prometheus_client::metrics::counter::Counter;
use prometheus_client::metrics::family::Family;
use prometheus_client::registry::Registry;
pub struct Metrics {
pub(crate) struct Metrics {
events: Family<EventLabels, Counter>,
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("relay");
let events = Family::default();

View File

@ -25,7 +25,7 @@ use prometheus_client::metrics::family::Family;
use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
use prometheus_client::registry::Registry;
pub struct Metrics {
pub(crate) struct Metrics {
connections_incoming: Family<AddressLabels, Counter>,
connections_incoming_error: Family<IncomingConnectionErrorLabels, Counter>,
@ -45,7 +45,7 @@ pub struct Metrics {
}
impl Metrics {
pub fn new(registry: &mut Registry) -> Self {
pub(crate) fn new(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("swarm");
let connections_incoming = Family::default();