Refine peer networking and chunked file transfers

This commit is contained in:
ddidderr
2025-11-11 20:56:03 +01:00
parent 3600b3ba6f
commit 936111e3c6
6 changed files with 748 additions and 188 deletions
+9 -1
View File
@@ -179,6 +179,8 @@ pub struct GameFileDescription {
pub game_id: String,
pub relative_path: String,
pub is_dir: bool,
#[serde(default)]
pub size: Option<u64>,
}
impl GameFileDescription {
@@ -186,6 +188,11 @@ impl GameFileDescription {
pub fn is_version_ini(&self) -> bool {
self.relative_path.ends_with("/version.ini")
}
#[must_use]
pub fn file_size(&self) -> Option<u64> {
if self.is_dir { None } else { self.size }
}
}
impl fmt::Debug for GameFileDescription {
@@ -193,10 +200,11 @@ impl fmt::Debug for GameFileDescription {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}: [{}] path:{}",
"{}: [{}] path:{} size:{}",
self.game_id,
if self.is_dir { 'D' } else { 'F' },
self.relative_path,
self.size.unwrap_or_default(),
)
}
}