Hello,
I’m exploring the option of using Rust + WebAssembly to speed up protobuf parsing. Everything works very well except for generating the output types. I explored two main options:
- Returning the Rust object directly
#[wasm_bindgen]
pub fn parse(bytes: Vec<u8>) -> Result<ProtobufObject, JsValue> {
}
but this results in:
the trait bound `Result<ProtobufObject, wasm_bindgen::JsValue>: ReturnWasmAbi` is not satisfied
the trait `ReturnWasmAbi` is not implemented for `Result<ProtobufObject, wasm_bindgen::JsValue>
- Generating types using the TypeScript library (ts-proto)
--ts_proto_opt=onlyTypes=true
--ts_proto_opt=useJsonWireFormat=true
--ts_proto_opt=forceLong=string
--ts_proto_opt=useOptionals=all
--ts_proto_opt=esModuleInterop=true
Here I was able to get almost compatible output, but protobuf bytes are generated as a base64 string by prost-serde and as Uint8Array by ts-proto. I can’t see an option to force either library to use the other format.
Is there any standard way to handle this kind of issue? Ideally, if the types could be generated automatically from the return type, that would be the best solution. Alternatively, the option to return a Uint8Array instead of a string would also be useful.
Hello,
I’m exploring the option of using Rust + WebAssembly to speed up protobuf parsing. Everything works very well except for generating the output types. I explored two main options:
but this results in:
Here I was able to get almost compatible output, but protobuf bytes are generated as a base64 string by prost-serde and as Uint8Array by ts-proto. I can’t see an option to force either library to use the other format.
Is there any standard way to handle this kind of issue? Ideally, if the types could be generated automatically from the return type, that would be the best solution. Alternatively, the option to return a Uint8Array instead of a string would also be useful.