feat(napi): redesign the Reference API ()

- Reference now is inject by #[napi] macro
- Class Reference and underlaying data now have the same lifetime
This commit is contained in:
LongYinan 2022-04-02 15:19:53 +08:00
parent 107539d906
commit 6eec0f93c1
7 changed files with 150 additions and 90 deletions
examples/napi/src

View file

@ -35,11 +35,9 @@ impl JsRepo {
}
#[napi]
pub fn remote(&self) -> Result<JsRemote> {
pub fn remote(&self, reference: Reference<JsRepo>, env: Env) -> Result<JsRemote> {
Ok(JsRemote {
inner: self
.create_reference()?
.share_with(|repo| Ok(repo.inner.remote()))?,
inner: reference.share_with(env, |repo| Ok(repo.inner.remote()))?,
})
}
}