Skip to content
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

Revisit wrapper API and check for correct lifetimes #125

Open
nicholastmosher opened this issue Dec 30, 2020 · 0 comments
Open

Revisit wrapper API and check for correct lifetimes #125

nicholastmosher opened this issue Dec 30, 2020 · 0 comments

Comments

@nicholastmosher
Copy link
Contributor

We should investigate making the wrapper API more ergonomic and error-resilient. There is some cruft having to do with raw pointers and some internal APIs that become error prone, such as in nj-core/src/basic.rs

pub fn unwrap<T>(&self, js_this: napi_value) -> Result<&'static T, NjError> { }

None of the values involved at the start of this invocation actually live for the full lifetime of the program, so there is the potential for memory unsoundness if it is not managed correctly. We need to craft the types with proper lifetimes that match the semantics of the node napi object lifetimes so that the Rust compiler will correct us on memory management.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant