Reputation: 642
I am trying to do something complex in rust with wasm_bindgen
I cannot export generic structs/functions from rust to javascript.
What I'm trying to do is something like this. some function
pub fn foo() -> (String, *const ()) {
let a: RandomType = //Create object
(a.get_metadata(), a.get_ptr())
}
This function will be exported to JS and here the String
will be the metadata.
another function
pub fn goo(metadata: String, ptr: *const ()) -> SomeType {
let a = //do something with metadata and ptr to get object
let b: SomeType = a.into();
}
of course, I will implement the Into
Trait for whatever type a
is supposed to be.
Basically, this type cannot be known at compile time. Is there a way to achieve this?
The Highlighted post talks about one function having 2 different return types and that is not what this is about at all. The return of function goo never changes. I just need a way to read data from a raw pointer.
Upvotes: 0
Views: 53