-
-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Description
Hi!
First of all, thanks for developing this crate, it works wonderfully :)
However, there is a scenario that I'd like to use this crate that I don't fully understand how to do it. I'd like to pass a binary data string to Rust code, and despite having a look at #31 I don't fully understand how to use this.
I have the following code
fn do_something(input: &[u8]) -> u64 {
// Do stuff
}
/// Computes some things
///
/// @param $input string Your input.
///
/// @return int Your result
#[php_function]
pub fn computation_rs(input: &str) -> u64 {
do_something(input.as_bytes())
}
// Required to register the extension with PHP.
#[php_module]
pub fn module(module: ModuleBuilder) -> ModuleBuilder {
module
}And my PHP code looks like
$data = random_bytes(32);
$result = computation_rs($data);
echo $result;If I replace $data with a valid string, this works, but I haven't managed to pass an array of bytes. I've tried setting the input type in rust to Vec<u8> but it didn't work either 🤔
Do you have any pointers?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels