diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-20 21:45:18 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-20 22:57:39 +0200 |
commit | 9ddb4d7786509bf5995bd5e254c611a05ea50eba (patch) | |
tree | de606bbb04f56e201eebdbf1a075595149441998 /server/registry/src/main.rs | |
parent | f2836d359942a6b42b1db9d1fd7624499798d925 (diff) | |
download | hurrycurry-9ddb4d7786509bf5995bd5e254c611a05ea50eba.tar hurrycurry-9ddb4d7786509bf5995bd5e254c611a05ea50eba.tar.bz2 hurrycurry-9ddb4d7786509bf5995bd5e254c611a05ea50eba.tar.zst |
reg: move structs to protocol crate
Diffstat (limited to 'server/registry/src/main.rs')
-rw-r--r-- | server/registry/src/main.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/server/registry/src/main.rs b/server/registry/src/main.rs index e979289f..9ba06e49 100644 --- a/server/registry/src/main.rs +++ b/server/registry/src/main.rs @@ -1,10 +1,11 @@ pub mod list; pub mod register; +use hurrycurry_protocol::registry::Entry; use list::{generate_html_list, generate_json_list, r_list}; use log::{error, info}; use register::r_register; -use rocket::{get, routes, serde::Serialize, Config}; +use rocket::{get, routes, Config}; use std::{ cmp::Reverse, collections::HashMap, @@ -48,7 +49,7 @@ fn main() { struct Registry { json_response: Arc<str>, html_response: Arc<str>, - servers: HashMap<u128, Entry>, + servers: HashMap<u128, InternalEntry>, } impl Registry { @@ -72,7 +73,7 @@ impl Registry { let mut list = self .servers .values() - .map(|e| PublicEntry { + .map(|e| Entry { name: e.name.clone(), address: e.address.keys().cloned().collect(), last_game: e.last_game, @@ -99,7 +100,7 @@ impl Registry { } #[derive(Debug)] -struct Entry { +struct InternalEntry { name: String, address: HashMap<String, Instant>, players_online: usize, @@ -107,16 +108,7 @@ struct Entry { version: (usize, usize), } -#[derive(Debug, Serialize)] -pub struct PublicEntry { - name: String, - address: Vec<String>, - players_online: usize, - last_game: i64, - version: (usize, usize), -} - -impl Default for Entry { +impl Default for InternalEntry { fn default() -> Self { Self { address: HashMap::new(), |