infinyon / infinyon/node-bindgen
Revisit wrapper API and check for correct lifetimes
- Dominant language
- Rust
- Stars
- 587
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
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(&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.
Contributor guide
Research direction
Start by reading `nj-core/src/basic.rs`, especially the `unwrap` signature, and trace how its raw pointers and returned lifetime relate to Node N-API object lifetimes. Review the surrounding wrapper APIs and determine the intended ownership semantics. Done means the types express those lifetimes and the Rust compiler can catch invalid memory-management assumptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, rust
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100