From f972e11fe5b410154bf4f2382b6c8e14bad5fb6d Mon Sep 17 00:00:00 2001 From: amrbashir Date: Sat, 19 Oct 2024 06:01:47 +0300 Subject: [PATCH] handle different target pointer width --- plugins/fs/src/commands.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index 04d3a277..f969326f 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -311,7 +311,21 @@ pub async fn read( // This is an optimization to include the number of read bytes (as bigendian bytes) // at the end of returned vector so we can use `tauri::ipc::Response` // and avoid serialization overhead of separate values. + #[cfg(target_pointer_width = "16")] + let nread = { + let nread = nread.to_be_bytes(); + let mut out = [0; 8]; + out[6..].copy_from_slice(&nread); + }; + #[cfg(target_pointer_width = "32")] + let nread = { + let nread = nread.to_be_bytes(); + let mut out = [0; 8]; + out[4..].copy_from_slice(&nread); + }; + #[cfg(target_pointer_width = "64")] let nread = nread.to_be_bytes(); + data.extend(nread); Ok(tauri::ipc::Response::new(data))