style(peer): format security hardening

Record the deterministic nightly rustfmt output for the newly added event-channel and retry code after the repository-wide formatter gate was repaired.

Test Plan:
- just fmt
- just clippy
- git diff --check
This commit is contained in:
2026-09-12 13:07:14 +02:00
parent f6af9b9420
commit 49f8eef7b5
10 changed files with 24 additions and 61 deletions
+2 -8
View File
@@ -110,10 +110,7 @@ pub(crate) struct OutboundTransferNotifier {
}
impl OutboundTransferNotifier {
fn new(
state: Arc<AtomicU8>,
tx_notify_ui: PeerEventSender,
) -> Self {
fn new(state: Arc<AtomicU8>, tx_notify_ui: PeerEventSender) -> Self {
Self {
state,
tx_notify_ui,
@@ -241,10 +238,7 @@ impl NetworkServiceCtx {
}
}
pub(crate) fn to_peer_ctx(
&self,
tx_notify_ui: PeerEventSender,
) -> PeerCtx {
pub(crate) fn to_peer_ctx(&self, tx_notify_ui: PeerEventSender) -> PeerCtx {
self.core.to_peer_ctx(tx_notify_ui, self.shutdown.clone())
}
}
@@ -9,7 +9,6 @@ use std::{
use futures::stream::FuturesUnordered;
use lanspread_db::content_manifest::ContentId;
use lanspread_proto::PeerEndpoint;
use crate::PeerEventSender;
use tokio_util::sync::CancellationToken;
use super::{
@@ -42,6 +41,7 @@ use crate::{
DownloadFailureReason,
DownloadVerificationActivity,
PeerEvent,
PeerEventSender,
content_quarantine::ContentQuarantine,
peer_db::PeerId,
quic_runtime::QuicConnector,
+6 -1
View File
@@ -425,7 +425,12 @@ mod tests {
.map(|index| {
source_at(
&format!("peer-{index}"),
[192, 0, 2, u8::try_from(index + 1).expect("source index fits")],
[
192,
0,
2,
u8::try_from(index + 1).expect("source index fits"),
],
12000 + index,
)
})
+6 -25
View File
@@ -14,7 +14,6 @@ use lanspread_db::{
db::GameDB,
};
use lanspread_proto::PeerEndpoint;
use crate::PeerEventSender;
use tokio_util::sync::CancellationToken;
#[cfg(test)]
@@ -25,6 +24,7 @@ use crate::{
DownloadVerificationActivity,
InstallOperation,
PeerEvent,
PeerEventSender,
StreamInstallSettings,
apply_launch_settings_to_verified_tree,
content_quarantine::ContentQuarantine,
@@ -545,11 +545,7 @@ async fn settle_download_completion(
}
/// Handles the `InstallGame` command.
pub async fn handle_install_game_command(
ctx: &Ctx,
tx_notify_ui: &PeerEventSender,
id: String,
) {
pub async fn handle_install_game_command(ctx: &Ctx, tx_notify_ui: &PeerEventSender, id: String) {
let games_folder = ctx.game_dir.read().await.clone();
spawn_install_operation(ctx, tx_notify_ui, OperationTarget::new(games_folder, id));
}
@@ -796,11 +792,7 @@ async fn select_stream_install_sources_or_finish(
}
/// Handles the `UninstallGame` command.
pub async fn handle_uninstall_game_command(
ctx: &Ctx,
tx_notify_ui: &PeerEventSender,
id: String,
) {
pub async fn handle_uninstall_game_command(ctx: &Ctx, tx_notify_ui: &PeerEventSender, id: String) {
let games_folder = ctx.game_dir.read().await.clone();
let target = OperationTarget::new(games_folder, id);
let ctx = ctx.clone();
@@ -1344,11 +1336,7 @@ fn promote_streamed_install(
Ok(())
}
fn spawn_install_operation(
ctx: &Ctx,
tx_notify_ui: &PeerEventSender,
target: OperationTarget,
) {
fn spawn_install_operation(ctx: &Ctx, tx_notify_ui: &PeerEventSender, target: OperationTarget) {
let ctx = ctx.clone();
let tx_notify_ui = tx_notify_ui.clone();
ctx.task_tracker.clone().spawn(async move {
@@ -1356,11 +1344,7 @@ fn spawn_install_operation(
});
}
async fn run_install_operation(
ctx: &Ctx,
tx_notify_ui: &PeerEventSender,
target: OperationTarget,
) {
async fn run_install_operation(ctx: &Ctx, tx_notify_ui: &PeerEventSender, target: OperationTarget) {
let id = target.game_id().to_owned();
let Some(prepared) = prepare_install_operation(ctx, tx_notify_ui, &target).await else {
return;
@@ -2342,10 +2326,7 @@ async fn handle_set_game_dir_command_with_drain_timeout(
}
/// Loads the configured local library and announces the result.
pub async fn load_local_library(
ctx: &Ctx,
tx_notify_ui: &PeerEventSender,
) -> eyre::Result<()> {
pub async fn load_local_library(ctx: &Ctx, tx_notify_ui: &PeerEventSender) -> eyre::Result<()> {
load_local_library_with_policy(ctx, tx_notify_ui, LocalLibraryEventPolicy::OnChange).await
}
+2 -6
View File
@@ -59,6 +59,7 @@ use std::{
pub use config::CHUNK_SIZE;
pub use error::PeerError;
pub use events::{PeerEventReceiver, PeerEventSender, peer_event_channel};
pub use identity::{
LoadedPeerIdentity,
PeerIdentity,
@@ -85,11 +86,7 @@ pub use peer_db::{
};
pub use scoped_blocking::scoped_blocking;
pub use scoped_process::{ScopedProcess, ScopedProcessOutput};
use tokio::sync::{
RwLock,
mpsc::UnboundedReceiver,
oneshot,
};
use tokio::sync::{RwLock, mpsc::UnboundedReceiver, oneshot};
use tokio_util::{sync::CancellationToken, task::TaskTracker};
pub use transfer_status::{
DownloadAttemptId,
@@ -134,7 +131,6 @@ pub use crate::{
StreamInstallProvider,
},
};
pub use events::{PeerEventReceiver, PeerEventSender, peer_event_channel};
// =============================================================================
// Public API types
@@ -808,11 +808,7 @@ fn send_state(tx_notify_ui: &PeerEventSender, state: LocalNetworkSharingState) {
);
}
fn report_failure(
tx_notify_ui: &PeerEventSender,
component: PeerRuntimeComponent,
error: String,
) {
fn report_failure(tx_notify_ui: &PeerEventSender, component: PeerRuntimeComponent, error: String) {
log::error!("{component:?} failed: {error}");
events::send(tx_notify_ui, PeerEvent::RuntimeFailed { component, error });
}
@@ -3,6 +3,7 @@
use std::{sync::Arc, time::Duration};
use futures::{StreamExt as _, stream};
use crate::{
PeerEventSender,
config::{PEER_PING_IDLE_SECS, PEER_PING_INTERVAL_SECS, peer_stale_timeout},
@@ -55,10 +55,7 @@ pub(crate) struct RemoteStateCtx {
impl RemoteStateCtx {
#[must_use]
pub(crate) fn from_network(
ctx: &NetworkServiceCtx,
tx_notify_ui: &PeerEventSender,
) -> Self {
pub(crate) fn from_network(ctx: &NetworkServiceCtx, tx_notify_ui: &PeerEventSender) -> Self {
Self {
local_peer_id: ctx.peer_id,
peer_game_db: ctx.peer_game_db.clone(),
@@ -371,10 +368,7 @@ fn enqueue_final_views(
/// Clears every remote projection after one network generation has fully
/// drained, then queues the authoritative replacement views while the
/// database-to-Call-to-Play lock order is still held.
pub(crate) async fn clear_remote_state_and_publish(
ctx: &Ctx,
tx_notify_ui: &PeerEventSender,
) {
pub(crate) async fn clear_remote_state_and_publish(ctx: &Ctx, tx_notify_ui: &PeerEventSender) {
let mut db = ctx.peer_game_db.write().await;
let mut call_to_play = ctx.call_to_play.write().await;
let retired = db.clear_remote_peers();
+1 -1
View File
@@ -23,9 +23,9 @@ use tokio_util::{sync::CancellationToken, task::TaskTracker};
use crate::{
PeerCommand,
PeerEventSender,
PeerId,
PeerIdentityDurability,
PeerEventSender,
PeerRuntimeComponent,
StreamInstallProvider,
Unpacker,
+2 -6
View File
@@ -10,10 +10,9 @@ use std::{
};
use serde::{Deserialize, Deserializer, Serialize, Serializer, de};
use crate::PeerEventSender;
use tokio_util::sync::CancellationToken;
use crate::{DownloadProgress, PeerEvent, events};
use crate::{DownloadProgress, PeerEvent, PeerEventSender, events};
static NEXT_DOWNLOAD_ATTEMPT_ID: AtomicU64 = AtomicU64::new(1);
@@ -457,10 +456,7 @@ impl ActiveDownloadSignal {
mod tests {
use super::*;
fn attempt() -> (
DownloadAttemptStatus,
crate::PeerEventReceiver,
) {
fn attempt() -> (DownloadAttemptStatus, crate::PeerEventReceiver) {
let (tx, rx) = crate::peer_event_channel();
(
DownloadAttemptStatus::new(