Coder Social home page Coder Social logo

Comments (5)

demurgos avatar demurgos commented on July 26, 2024 1

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.

kjvalencik avatar kjvalencik commented on July 26, 2024

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.

stevenliebregt avatar stevenliebregt commented on July 26, 2024

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.

kjvalencik avatar kjvalencik commented on July 26, 2024

That's what reference counting like an Arc does. It makes it cloneable (cloning increments the counter instead of copying the struct).

from neon.

stevenliebregt avatar stevenliebregt commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.