wasm_bindgen doesn't generate because struct S has generic Type T. However I just want wasm_bindgen to generate on specific type like S<u8>. Whatever the methods declared in S<T> should be available to S<u8> by wasm_bindgen. What is the syntax for achieving like this?
If I understand it correctly, I think the problem is that this is about generating bindings for a foreign interface, so the types need to be concrete for wasm_bindgen to work.
The way out is probably gonna be using a newtype:
#[wasm_bindgen]
struct ConcreteU8S(S<u8>)
This does, however, mean that you'll need to write the forwarding/proxying of the methods you want yourself. As in:
impl ConcreteU8S {
fn do_something(&self) {
self.0.do_something()
}
/// repeat for everything you care about
}
I'm no expert in with wasm_bindgen, so I didn't respond initially, but given your plea -- my impression is exactly in line with what @errado said. You'll need to make a newtype and forward the methods.
I believe there is no macro that could be written to automate this. Why?
Because every interface is different. Just deciding which types you want to substitute for type parameters at the FFI boundary alone is something a macro is incapable of having knowledge of.
A macro could be written to reduce the amount of boilerplate, but that would make the process a lot more magick, and so I think it would be a bad idea to attempt that.