yrashk / bpxe.rs

Business Process eXecution Engine
Apache License 2.0
36 stars 10 forks source link

Problem: usage of intertrait crate #10

Closed yrashk closed 3 years ago

yrashk commented 3 years ago

We're currently using intertrait, which depends on linkme. While it works on Linux, macOS and Windows, it might not work elsewhere as it's platform-dependent.

In fact, there's no support for WebAssembly: https://github.com/dtolnay/linkme/issues/6 and that's one of the goals for BPXE.

Solution: roll our own Cast trait

It's a bit crude and is certainly less ergonomic (compared to intertrait) but it seems to work.

The idea is to make DocumentElement trait implement Cast<T> where T is all Type and TypeMut traits and then auto-generate implementations of this Cast<T> trait for every struct and enum.

One downside of this approach is that autogenerated.rs is much bigger now (approaching 7Mb). That being said, it might eventually be generated during build-time and we won't have to distribute it as is. I suppose the amount of actual code generated by trait casting crates is effectively of a similar size.

Closes #8