From 5aae8d01fc2a91e21e9a1e69b916df351eb53404 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sat, 28 Feb 2026 16:03:58 +0300 Subject: [PATCH] Include content size in Zstd frame header Figma requires the Zstd content size to be present in the frame header. Use zstd::Encoder with include_contentsize(true) instead of encode_all. --- desktop/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/desktop/src/lib.rs b/desktop/src/lib.rs index bab9adec2..b8abeb3b9 100644 --- a/desktop/src/lib.rs +++ b/desktop/src/lib.rs @@ -5,7 +5,13 @@ use tauri::{ #[tauri::command] fn zstd_compress(data: Vec) -> Result, String> { - zstd::encode_all(data.as_slice(), 3).map_err(|e| e.to_string()) + use std::io::Write; + let mut encoder = zstd::Encoder::new(Vec::new(), 3).map_err(|e| e.to_string())?; + encoder + .include_contentsize(true) + .map_err(|e| e.to_string())?; + encoder.write_all(&data).map_err(|e| e.to_string())?; + encoder.finish().map_err(|e| e.to_string()) } #[cfg_attr(mobile, tauri::mobile_entry_point)]