ChatGPT Codex 5.2 xhigh refactored > 45min

This commit is contained in:
2026-01-13 18:59:12 +01:00
parent f76d59265c
commit b60dcef471
15 changed files with 1672 additions and 367 deletions
+69
View File
@@ -2,6 +2,67 @@ use bytes::Bytes;
use lanspread_db::db::{Game, GameFileDescription};
use serde::{Deserialize, Serialize};
pub const PROTOCOL_VERSION: u32 = 2;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub enum Availability {
Ready,
Downloading,
LocalOnly,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct GameSummary {
pub id: String,
pub name: String,
pub size: u64,
pub downloaded: bool,
pub installed: bool,
pub eti_version: Option<String>,
pub manifest_hash: u64,
pub availability: Availability,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Hello {
pub peer_id: String,
pub proto_ver: u32,
pub library_rev: u64,
pub library_digest: u64,
pub features: Vec<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct HelloAck {
pub peer_id: String,
pub proto_ver: u32,
pub library_rev: u64,
pub library_digest: u64,
pub features: Vec<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LibrarySummary {
pub library_rev: u64,
pub library_digest: u64,
pub game_count: usize,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LibrarySnapshot {
pub library_rev: u64,
pub games: Vec<GameSummary>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LibraryDelta {
pub from_rev: u64,
pub to_rev: u64,
pub added: Vec<GameSummary>,
pub updated: Vec<GameSummary>,
pub removed: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum Request {
Ping,
@@ -17,6 +78,13 @@ pub enum Request {
length: u64,
},
AnnounceGames(Vec<Game>),
Hello(Hello),
LibrarySummary(LibrarySummary),
LibrarySnapshot(LibrarySnapshot),
LibraryDelta(LibraryDelta),
Goodbye {
peer_id: String,
},
Invalid(Bytes, String),
}
@@ -28,6 +96,7 @@ pub enum Response {
id: String,
file_descriptions: Vec<GameFileDescription>,
},
HelloAck(HelloAck),
GameNotFound(String),
InvalidRequest(Bytes, String),
EncodingError(String),