Skip to content

Commit

Permalink
handle different target pointer width
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 19, 2024
1 parent b0e8033 commit f972e11
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/fs/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,21 @@ pub async fn read<R: Runtime>(
// 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))
Expand Down

0 comments on commit f972e11

Please sign in to comment.