From a50e0999ca6b6ba701d42de71207e70915d4b559 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 30 Mar 2024 12:18:07 +0100 Subject: [PATCH] Remove Stop and Rip commands --- showbits-thermal-printer/src/drawer.rs | 8 -------- showbits-thermal-printer/src/server.rs | 10 ---------- 2 files changed, 18 deletions(-) diff --git a/showbits-thermal-printer/src/drawer.rs b/showbits-thermal-printer/src/drawer.rs index 9f29336..af3c93a 100644 --- a/showbits-thermal-printer/src/drawer.rs +++ b/showbits-thermal-printer/src/drawer.rs @@ -28,8 +28,6 @@ pub trait Drawing { pub struct BoxedDrawing(Box); pub enum Command { - Stop, - Rip, Draw(BoxedDrawing), Test, @@ -72,10 +70,6 @@ impl Drawer { pub fn run(&mut self) -> anyhow::Result<()> { while let Some(command) = self.rx.blocking_recv() { - if matches!(command, Command::Stop) { - break; - }; - self.on_command(command)?; } Ok(()) @@ -83,8 +77,6 @@ impl Drawer { fn on_command(&mut self, command: Command) -> anyhow::Result<()> { match command { - Command::Stop => {} // Already handled one level above - Command::Rip => self.printer.rip()?, Command::Draw(drawing) => drawing.0.draw(&mut self.printer, &mut self.ctx)?, Command::Test => self.on_test()?, diff --git a/showbits-thermal-printer/src/server.rs b/showbits-thermal-printer/src/server.rs index 5f54b29..ec5b40d 100644 --- a/showbits-thermal-printer/src/server.rs +++ b/showbits-thermal-printer/src/server.rs @@ -23,9 +23,7 @@ struct Server { pub async fn run(tx: mpsc::Sender, addr: String) -> anyhow::Result<()> { let app = Router::new() - .route("/stop", post(post_stop)) .route("/test", post(post_test)) - .route("/rip", post(post_rip)) .route("/text", post(post_text)) .route("/image", post(post_image).fallback(get_static_file)) .route("/photo", post(post_photo).fallback(get_static_file)) @@ -41,18 +39,10 @@ pub async fn run(tx: mpsc::Sender, addr: String) -> anyhow::Result<()> Ok(()) } -async fn post_stop(server: State) { - let _ = server.tx.send(Command::Stop).await; -} - async fn post_test(server: State) { let _ = server.tx.send(Command::Test).await; } -async fn post_rip(server: State) { - let _ = server.tx.send(Command::Rip).await; -} - #[derive(Deserialize)] struct PostTextForm { text: String,