Skip to content

Overhaul the conversion traits #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

alexcrichton
Copy link
Contributor

This commit overhauls the conversion traits used for types crossing the Rust/JS
boundary. Previously there were a few ad-hoc traits but now there's only two.
One is for converting JS values to Rust values, FromWasmAbi, and the other is
for converting Rust values into JS values, IntoWasmAbi. These two traits are
now uniformly used for all operations such as creating references and such.

The IntoWasmAbi trait is pretty straightforward but FromWasmAbi is much
trickier. We need to be able to create references which necessitates a good deal
of funkiness with the API, but it in general should work out alright.

The goal of this commit is to reduce the number of traits in play so it's more
straightforward which traits are used for closures.

This commit overhauls the conversion traits used for types crossing the Rust/JS
boundary. Previously there were a few ad-hoc traits but now there's only two.
One is for converting JS values to Rust values, `FromWasmAbi`, and the other is
for converting Rust values into JS values, `IntoWasmAbi`. These two traits are
now uniformly used for all operations such as creating references and such.

The `IntoWasmAbi` trait is pretty straightforward but `FromWasmAbi` is much
trickier. We need to be able to create references which necessitates a good deal
of funkiness with the API, but it in general should work out alright.

The goal of this commit is to reduce the number of traits in play so it's more
straightforward which traits are used for closures.
@alexcrichton
Copy link
Contributor Author

This is a necessary prerequisite for #104

@alexcrichton
Copy link
Contributor Author

Oh dear I ended up merging this in 0e6325d rather than pushing to this commit by accident.

In any case I realized right after posting this that these traits as written aren't sound, so I had to scale back and be a bit more conservative in the referenced commit (namely having multiple traits for creating Rust values from JS ones.

@alexcrichton alexcrichton deleted the new-conversions branch April 15, 2018 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant