aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands/qr.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 01:11:50 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 01:11:50 +0100
commitfd93334a21907f959018e1b1f5df747a98d186c8 (patch)
tree259e595a570b42a5ea082f596e1cb97e5011cfba /src/commands/qr.rs
parenthttp: add connect and request timeouts (diff)
downloadsenator-sperma-fd93334a21907f959018e1b1f5df747a98d186c8.tar.gz
senator-sperma-fd93334a21907f959018e1b1f5df747a98d186c8.zip
processes: add timeouts and keep decoding off the runtime
Diffstat (limited to '')
-rw-r--r--src/commands/qr.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/commands/qr.rs b/src/commands/qr.rs
index 26232ee..c0b8af0 100644
--- a/src/commands/qr.rs
+++ b/src/commands/qr.rs
@@ -61,10 +61,14 @@ pub async fn dekodowanie(
61 .await? 61 .await?
62 .bytes() 62 .bytes()
63 .await?; 63 .await?;
64 let img = image::load_from_memory(&img_data)?; 64 // Decoding is CPU-heavy: keep it off the async runtime.
65 let gray = img.to_luma8(); 65 let img_data = img_data.to_vec();
66 66 let decoded = tokio::task::spawn_blocking(move || {
67 let decoded = decode_qr_simple(&gray); 67 let img = image::load_from_memory(&img_data).ok()?;
68 let gray = img.to_luma8();
69 decode_qr_simple(&gray)
70 })
71 .await?;
68 match decoded { 72 match decoded {
69 Some(text) => { 73 Some(text) => {
70 ctx.say(lang::fmt_qr_decoded(&text)).await?; 74 ctx.say(lang::fmt_qr_decoded(&text)).await?;