neon-bindings / neon

Rust bindings for writing safe and fast native Node.js modules.
https://www.neon-bindings.com/
Apache License 2.0
7.98k stars 282 forks source link

Replace all generic contexts with a single Cx type #1048

Closed kjvalencik closed 4 days ago

kjvalencik commented 3 months ago

This allows users to take Cx as an argument instead of being generic over the Context trait. For example, this will allow us to implement TryIntoJs for closures.

This is technically a breaking change because several context types have been replaced by type aliases; if a user were implementing a trait over multiple of these types, it would now cause a conflict. In practice, users either didn't do this at all or implemented it generically over the Context trait.

We could keep the existing types, it just makes it harder to deprecate them in the future. For a Neon 2.0, I would want to eliminate the Context trait and only make it concrete. The special needs of function and module would become additional arguments.

kjvalencik commented 1 month ago

@dherman I marked them #[doc(hidden)] and removed all references to them internally. In the future, we will likely want to mark them deprecated.