From fc4a38b28e6896670e727416b0afae657f997c94 Mon Sep 17 00:00:00 2001 From: Jose Fernandez Date: Sun, 15 Mar 2026 12:09:11 -0600 Subject: [PATCH 1/2] refactor: remove unused websocket message variants --- src/app.rs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/app.rs b/src/app.rs index 2ea8072..9408af9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -42,18 +42,10 @@ fn template_env() -> &'static Environment<'static> { }) } -#[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(tag = "type")] -enum ClientMessage { - Ping, - RequestRefresh, -} - #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(tag = "type")] enum ServerMessage { Reload, - Pong, } use std::collections::HashMap; @@ -682,13 +674,7 @@ async fn handle_websocket(socket: WebSocket, state: SharedMarkdownState) { let recv_task = tokio::spawn(async move { while let Some(msg) = receiver.next().await { match msg { - Ok(Message::Text(text)) => { - if let Ok(client_msg) = serde_json::from_str::(&text) { - match client_msg { - ClientMessage::Ping | ClientMessage::RequestRefresh => {} - } - } - } + Ok(Message::Text(_)) => {} Ok(Message::Close(_)) => break, _ => {} } From 4f4adaa67c75acf4a2f9ecdabdf5da0d588f6a79 Mon Sep 17 00:00:00 2001 From: Jose Fernandez Date: Sun, 15 Mar 2026 12:15:50 -0600 Subject: [PATCH 2/2] fix: resolve irrefutable pattern warnings in tests With Pong removed, ServerMessage has only one variant (Reload), making `if let ServerMessage::Reload` irrefutable. Replace verbose match blocks with simple `.expect()` calls. --- src/app.rs | 69 ++++++------------------------------------------------ 1 file changed, 7 insertions(+), 62 deletions(-) diff --git a/src/app.rs b/src/app.rs index 9408af9..5de3d47 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1003,18 +1003,7 @@ mod tests { ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after file modification"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after file modification"); - } - } + update_result.expect("Timeout waiting for WebSocket update after file modification"); } #[tokio::test] @@ -1445,18 +1434,7 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after file modification"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after file modification"); - } - } + update_result.expect("Timeout waiting for WebSocket update after file modification"); } #[tokio::test] @@ -1476,18 +1454,7 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after new file creation"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after new file creation"); - } - } + update_result.expect("Timeout waiting for WebSocket update after new file creation"); let response = server.get("/test1.md").await; assert_eq!(response.status_code(), 200); @@ -1687,18 +1654,7 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after temp file rename"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after temp file rename"); - } - } + update_result.expect("Timeout waiting for WebSocket update after temp file rename"); let final_response = server.get("/").await; assert_eq!(final_response.status_code(), 200); @@ -1747,20 +1703,9 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after temp file rename in directory mode"); - } - } - Err(_) => { - panic!( - "Timeout waiting for WebSocket update after temp file rename in directory mode" - ); - } - } + update_result.expect( + "Timeout waiting for WebSocket update after temp file rename in directory mode", + ); let final_response = server.get("/test1.md").await; assert_eq!(final_response.status_code(), 200);