MOZGIII / xwt

A unified WebTransport API that you can use for browser/native cross platform apps. Originally to power the networking layer of the games made with the bevy engine - but can be applied elsewhere too.
31 stars 4 forks source link

Hand-crafted WebTransport Web API bindings #129

Closed MOZGIII closed 4 days ago

MOZGIII commented 5 months ago

This is a replacement for the web-sys crate (and https://github.com/MOZGIII/xwt/pull/117), hard-written instead of being code-generated to overcome the current shortcomings of the wasm_bindgen_webidl codegen and its choices. See more on that: https://github.com/rustwasm/wasm-bindgen/issues/3921


The rationale for the hard-written bindings are greater for the development experience, since you get the code that doesn't have JsValues as return types - but a much saner types without a need for manual conversion (this is actually something that we had bugs with before), but also performance gains, since we can add final clause to the wasm_bindgen macro invocation for more efficient bindings at the hot I/O paths.

The hand crafted bindings turned out to be much more comprehensive and useful than the generated ones - because the generated bindings just lack some huge parts of the API surface, and other part of the API are simply generated wrong and/or unusable due to invalid assumptions of the code generator. Needless to say, the generated code is just not ergonomic without a real reason for it - must be a shortcoming of the generator, and most likely fixable - see https://github.com/rustwasm/wasm-bindgen/issues/3921.


To do:

MOZGIII commented 1 month ago

https://github.com/rustwasm/wasm-bindgen/pull/3919 has been merged, we can finally proceed

MOZGIII commented 1 month ago

Now this is blocked by wasm-bindgen release: https://github.com/rustwasm/wasm-bindgen/pull/3993#issuecomment-2254654479

MOZGIII commented 1 month ago

Finally this is fully unblocked!