| Crates.io | server-function |
| lib.rs | server-function |
| version | 0.1.3 |
| created_at | 2022-11-22 22:45:30.162096+00 |
| updated_at | 2022-12-20 09:55:54.563133+00 |
| description | A macro for easy RPC creation |
| homepage | https://github.com/r4nd0m1z3r/server-function |
| repository | https://github.com/r4nd0m1z3r/server-function |
| max_upload_size | |
| id | 721175 |
| size | 43,405 |
This is a macro for RPC programming needs which generates a structure and a thunk for function in a way that allows calling that function with a struct argument that supports serde::Deserialize
Mark function with #[server_function] attribute
#[server_function]
fn add(a: u32, b: u32) -> u32 {
a + b
}
This will generate AddArgs struct matching your function arguments that looks like this
struct AddArgs {
a: u32,
b: u32
}
and a function named add_thunk with AddArgs struct as 1 argument
Now you can call it
// will return 10, same as original function
add_thunk(AddArgs { a: 5, b: 5 })
Enables rmp-serde and allows server function to be called using raw messagepack bytes using with_bytes_thunk(bytes: &[u8])
let bytes = rmp_serde::to_vec(AddArgs { a: 5, b: 5 }).unwrap();
add_messagepack_thunk(&bytes) // should return 10