Five files ran between 1.2k and 2.4k lines, and one function past the length the quality gate allows. None of it was doing anything wrong; they had simply accumulated until you had to scroll to hold one in your head. The move throughout is into *child* modules rather than siblings, because a child still sees its parent's private items. So `ClientContext` keeps its private fields and `ServerActor` keeps its private state, while the methods that work on them move out — no encapsulation is widened for the sake of the split. Three `ServerActor` methods become `pub(super)`, which is only acknowledging the calls the parent already made. The client's operation loop and the actor's standing-message match are split by subject: the arms move out whole, so the bodies read exactly as they did inside. Where an arm said `continue` it now says `return` — the match was the last thing the loop did, and none of the arms that moved holds a loop of its own, so skipping the rest of an arm and ending its handler are the same move. The test modules split by topic the same way, which is most of the size: main_tui's alone was 2.1k of the 2.4k lines. No behaviour changes. Verified against a live server: the full e2e suite passes, including the 98 CLI and 19 daemon-protocol cases that drive the dispatch loop this touches.
53 lines
1.1 KiB
Rust
53 lines
1.1 KiB
Rust
//! The client's context, exercised directly.
|
|
//!
|
|
//! This file is the harness the topic modules below share.
|
|
|
|
mod peers;
|
|
mod rooms;
|
|
mod search;
|
|
mod transfers;
|
|
mod users;
|
|
|
|
use super::*;
|
|
|
|
fn download(
|
|
username: &str,
|
|
filename: &str,
|
|
token: u32,
|
|
status: DownloadStatus,
|
|
sender: Sender<DownloadStatus>,
|
|
) -> Download {
|
|
Download {
|
|
username: username.to_string(),
|
|
filename: filename.to_string(),
|
|
token,
|
|
size: 100,
|
|
download_directory: "test".to_string(),
|
|
status,
|
|
sender,
|
|
queue_position: None,
|
|
metadata: DownloadMetadata::default(),
|
|
}
|
|
}
|
|
|
|
fn peer_files(count: usize) -> SearchResult {
|
|
SearchResult {
|
|
token: 1,
|
|
files: (0..count)
|
|
.map(|i| crate::types::File {
|
|
username: "bob".to_string(),
|
|
name: format!("song-{i}.mp3"),
|
|
size: 1,
|
|
attribs: std::collections::HashMap::new(),
|
|
})
|
|
.collect(),
|
|
slots: 1,
|
|
speed: 0,
|
|
username: "bob".to_string(),
|
|
}
|
|
}
|
|
|
|
use crate::types::{RoomEvent, UploadStatus};
|
|
|
|
use std::time::{Duration, Instant};
|