summaryrefslogtreecommitdiffstats
path: root/src/transport/traffic.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-26 21:48:54 +0100
committertv <tv@krebsco.de>2026-10-26 21:48:54 +0100
commitecdb3ee944f5c171faac3a71117e2ff27e064295 (patch)
treea8e35f4dec4de93c7d53416da43fc4f9a3a381ed /src/transport/traffic.rs
parent7135c860db4169bfc9a06838cf637350ef68c0c0 (diff)
turn all pub into pub(crate)
Diffstat (limited to 'src/transport/traffic.rs')
-rw-r--r--src/transport/traffic.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs
index 7d245ac..6c3d683 100644
--- a/src/transport/traffic.rs
+++ b/src/transport/traffic.rs
@@ -19,9 +19,9 @@ use crate::locks::MutexExt;
use crate::transport::{EncodedMessage, MessageHandler, MessageKind, ParsedMessage, Transport};
#[derive(Debug, Default, Clone, Copy, Serialize)]
-pub struct Counter {
- pub messages: u64,
- pub bytes: u64,
+pub(crate) struct Counter {
+ pub(crate) messages: u64,
+ pub(crate) bytes: u64,
}
impl Counter {
@@ -33,13 +33,13 @@ impl Counter {
#[derive(Debug, Default, Clone, Copy, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct ByKind {
- pub hello: Counter,
- pub hello_reply: Counter,
- pub sync: Counter,
- pub ping: Counter,
- pub pong: Counter,
- pub blob: Counter,
+pub(crate) struct ByKind {
+ pub(crate) hello: Counter,
+ pub(crate) hello_reply: Counter,
+ pub(crate) sync: Counter,
+ pub(crate) ping: Counter,
+ pub(crate) pong: Counter,
+ pub(crate) blob: Counter,
}
impl ByKind {
@@ -57,12 +57,12 @@ impl ByKind {
#[derive(Debug, Default, Clone, Copy, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct PeerTraffic {
+pub(crate) struct PeerTraffic {
/// Handed to Mycelium (it accepted them).
- pub sent: ByKind,
- pub received: ByKind,
+ pub(crate) sent: ByKind,
+ pub(crate) received: ByKind,
/// Sends Mycelium refused (e.g. no route to the peer); not counted as sent.
- pub refused: ByKind,
+ pub(crate) refused: ByKind,
}
#[derive(Debug, Default)]
@@ -73,7 +73,7 @@ struct Table {
}
#[derive(Debug, Default)]
-pub struct Traffic {
+pub(crate) struct Traffic {
table: Mutex<Table>,
}
@@ -104,29 +104,29 @@ impl Traffic {
self.count(peer, bytes, |t| t.received.get_mut(kind));
}
- pub fn peer(&self, peer: &str) -> Option<PeerTraffic> {
+ pub(crate) fn peer(&self, peer: &str) -> Option<PeerTraffic> {
self.lock().peers.get(peer).copied()
}
- pub fn total(&self) -> PeerTraffic {
+ pub(crate) fn total(&self) -> PeerTraffic {
self.lock().total
}
/// Drops the counters of peers not kept (anyone can send us messages; the totals
/// keep their share).
- pub fn retain(&self, mut keep: impl FnMut(&str) -> bool) {
+ pub(crate) fn retain(&self, mut keep: impl FnMut(&str) -> bool) {
self.lock().peers.retain(|peer, _| keep(peer));
}
}
/// Counts what passes through `inner`.
-pub struct CountingTransport {
+pub(crate) struct CountingTransport {
inner: Arc<dyn Transport>,
traffic: Arc<Traffic>,
}
impl CountingTransport {
- pub fn new(inner: Arc<dyn Transport>, traffic: Arc<Traffic>) -> Self {
+ pub(crate) fn new(inner: Arc<dyn Transport>, traffic: Arc<Traffic>) -> Self {
Self { inner, traffic }
}
}