diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | src/types.rs | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 2b5f9b1..2f7d52c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,16 @@ async fn tokio_main(conf: Config) -> Result<(), Box<dyn Error>> { let style = path!("s.css").and(fs::file(conf.stylesheet.clone())); let code = path!("c.js").and(fs::file(conf.client_code.clone())); let font = path!("f.ttf").map(|| FONT_FILE); - let listing = path!("rlist").map(|| "placeholder'em"); + let listing = { + let pubs = public_rooms.clone(); + path!("rlist").and_then(move || { + let pubs = pubs.clone(); + async move { + Ok::<_,std::convert::Infallible>( + reply::json(&pubs.read().await.as_slice()) + ) + }}) + }; let rform_recv = { let rooms = rooms.clone(); let pubs = public_rooms.clone(); diff --git a/src/types.rs b/src/types.rs index 1c9ae89..84e7d46 100644 --- a/src/types.rs +++ b/src/types.rs @@ -62,13 +62,18 @@ impl Display for Player { } } -#[derive(Eq, PartialEq, Hash, Debug, Clone)] +#[derive(Eq, PartialEq, Hash, Debug, Clone, serde::Serialize)] pub struct RoomId(pub String); impl Display for RoomId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } +impl std::borrow::Borrow<str> for RoomId { + fn borrow(&self) -> &str { + self.0.borrow() + } +} impl RoomId { pub fn new_in<T>(map: &HashMap<RoomId, T>) -> Self { |