allsey87 / web-rpc

Bi-directional RPC for the Web
MIT License
6 stars 0 forks source link

Support `JsValue`'s inside Result and Option types #2

Open allsey87 opened 6 days ago

allsey87 commented 6 days ago

The arguments of RPC currently have to be either serializable or JsValue. Ideally, this restriction should be relaxed to allow composite types, e.g., an arbitrary struct or enum containing a JsValue to be sent across a channel, however, at a bare minimum it should be possible to have RPC calls that can return a Result<T, JsValue> since this pattern is used to represent exceptions from Javascript code.

allsey87 commented 6 days ago

Note that only some errors are supported by the structured clone algorithm: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#javascript_types