Added a note to discourage using isize and usize (#123)

* Update 25_server_functions.md

Add note on Number sizes

* Update src/server/25_server_functions.md

Co-authored-by: Jérôme MEVEL <2572775+jmevel@users.noreply.github.com>

---------

Co-authored-by: Ben Wishovich <benwis@users.noreply.github.com>
Co-authored-by: Jérôme MEVEL <2572775+jmevel@users.noreply.github.com>
This commit is contained in:
Jesse Hoobergs
2025-10-02 00:04:36 +02:00
committed by GitHub
parent a2597a8a1d
commit 4ac86072ed

View File

@@ -116,6 +116,11 @@ pub async fn create_user(name: String, email: String) -> Result<User, AppError>
}
```
## An Important Note on Number Sizes
When using Server functions, one should not use pointer-sized integer types such as `isize` and `usize` as the pointer-size of the server will probably be 64 bits, while the pointer-size in Wasm is 32 bits.
This will lead to a deserialization error when the server sends a number which does not fit in 32 bits. Use fixed size types such as `i32` or `i64` to mitigate this problem.
## Integrating Server Functions with Leptos
So far, everything Ive said is actually framework agnostic. (And in fact, the Leptos server function crate has been integrated into Dioxus as well!) Server functions are simply a way of defining a function-like RPC call that leans on Web standards like HTTP requests and URL encoding.