From 3578a279c52486872ff8cab11f6dad6f01c3fcaf Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 16 May 2024 23:26:57 +0200 Subject: [PATCH] update to servicepoint2 v0.4.0 --- Cargo.lock | 42 +++++++++++++++++++----------------------- Cargo.toml | 2 +- src/execute_command.rs | 2 +- src/gui.rs | 4 ++-- src/main.rs | 11 ++++++++--- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a1c8b9..e706e34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1018,26 +1018,6 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" -[[package]] -name = "lz4" -version = "1.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" -dependencies = [ - "libc", - "lz4-sys", -] - -[[package]] -name = "lz4-sys" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "malloc_buf" version = "0.0.6" @@ -1527,6 +1507,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "rust-lzma" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d62915608f6cee1d7f2fc00f28b4f058ff79d6e4ec3c2fe0006b09b52437c84" +dependencies = [ + "pkg-config", + "vcpkg", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -1632,14 +1622,14 @@ dependencies = [ [[package]] name = "servicepoint2" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d434890b6d1a4c886f384639bf79ba7f127221cad7bff45acabf99d2fccee5f" +checksum = "e271ff29f683581a14d1712f76c0cf2dad956725cc1f36228ddde8ea783055cf" dependencies = [ "bzip2", "flate2", "log", - "lz4", + "rust-lzma", "zstd", ] @@ -1872,6 +1862,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 44b638a..e49226f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later" [dependencies] # packet parsing -servicepoint2 = "0.2.0" +servicepoint2 = "0.4.0" # gui winit = { version = "0.30", features = ["rwh_05"] } # for creating a window diff --git a/src/execute_command.rs b/src/execute_command.rs index 4015c39..b9db971 100644 --- a/src/execute_command.rs +++ b/src/execute_command.rs @@ -23,7 +23,7 @@ pub(crate) fn execute_command( warn!("display shutting down"); return false; } - Command::BitmapLinearWin(Origin(x, y), pixels) => { + Command::BitmapLinearWin(Origin(x, y), pixels, _) => { let mut display = display_ref.write().unwrap(); print_pixel_grid(x as usize, y as usize, &pixels, &mut display); } diff --git a/src/gui.rs b/src/gui.rs index 379a906..713ec37 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -2,10 +2,10 @@ use std::sync::mpsc::Sender; use std::sync::RwLock; use log::{info, warn}; -use pixels::{Pixels, PixelsBuilder, SurfaceTexture}; use pixels::wgpu::TextureFormat; +use pixels::{Pixels, PixelsBuilder, SurfaceTexture}; use servicepoint2::{ - ByteGrid, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid, TILE_SIZE, + ByteGrid, PixelGrid, PIXEL_HEIGHT, PIXEL_WIDTH, TILE_SIZE, }; use winit::application::ApplicationHandler; use winit::dpi::{LogicalSize, Size}; diff --git a/src/main.rs b/src/main.rs index 367a2b1..e62ec47 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use std::time::Duration; use clap::Parser; use log::{info, warn}; use servicepoint2::{ - ByteGrid, Command, PixelGrid, PIXEL_HEIGHT, PIXEL_WIDTH, TILE_HEIGHT, + ByteGrid, Command, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid, TILE_HEIGHT, TILE_WIDTH, }; use winit::event_loop::{ControlFlow, EventLoop}; @@ -102,8 +102,13 @@ fn run( ); } - let vec = buf[..amount].to_vec(); - let package = servicepoint2::Packet::from(vec); + let package = match servicepoint2::Packet::try_from(&buf[..amount]) { + Err(_) => { + warn!("could not load packet with length {amount} into header"); + continue; + } + Ok(package) => package, + }; let command = match Command::try_from(package) { Err(err) => {