Comments (5)
After you return the value it is managed by the JS VM. The result must be 'static
. If RowIter
borrows from something, it is not compatible and you need to refactor your code to avoid this non-static lifetime.
You could maybe consider moving the connection with the stream using some of the crates enabling self-referential structs.
from neon.
The issue is that repo
is borrowing from repo_wrapper
. When a value is put in a JsBox
, ownership is transferred to the JavaScript runtime and you can only get references afterwards.
The typical pattern in Rust
for this is to wrap the value in an Arc
.
from neon.
As far as I see I can't make this work with Neon, I tried looking at the gzip-stream
example, but that uses Clone
which I can't use as the underlying connection also isn't cloneable.
from neon.
That's what reference counting like an Arc does. It makes it cloneable (cloning increments the counter instead of copying the struct).
from neon.
I feel like I'm not clear enough on what my problem exactly is, but I have a hard time explaining it.
The Repo
has a postgres::Client
and has a method fn query_many_stream(&mut self) -> Result<postgres::RowIter, Error>
this RowIter
has a lifetime 'a
to the connection.
I have a hard time seeing what part exactly I should wrap in a Mutex, any help is much appreciated.
from neon.
Related Issues (20)
- Hope support Node 18.x HOT 3
- Feature request: Safer SysContext via thread-locals HOT 7
- Added into awesome directory HOT 1
- The garbage collector thinks my object is garbage :( HOT 1
- Question: Calling JS callbacks in rayon HOT 2
- Seg fault when linked with a C library HOT 8
- How to callback as event handler multiple times from multiple threads? HOT 2
- Capturing a function to call it later? HOT 5
- Binding variable from main into callable function HOT 4
- How to turn Rust Image buffer Vec<u8> to JsBuffer? HOT 2
- `register_module!` is unhygenic HOT 1
- Clean-up sys bindings orgnaization
- Remove the `build` function
- Trouble passing this to an async method in a neon class HOT 3
- Question: Logging HOT 4
- Can not work on Windows HOT 2
- Bindings blocking node runtime? HOT 6
- neon error when installing native-voxel-generator HOT 1
- Move `root` method to `Value` trait HOT 1
- JsError doesn't work on non-wasm targets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neon.