Skip to content

Revisit wrapper API and check for correct lifetimes #125

Description

@nicholastmosher

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions