You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to give my plugins access to stuff on the host's database. What I'd normally do, is pass my Store struct around, which contains methods that you can do to get access to the database. Of course I can't do this with plugins, as the Store cannot pass the memory boundary. So what I could do, is create a query function in my host, and expose that in the plugin runtime. That query function will still need to access my Store. In some programming languages, you might use some global context and take the Store from there, but that's not an option in Rust I think: I need to pass my Store explicitly to my new query function. But how can I do this?
However, I have no idea on how I can then pass some context to my runtime, so that my runtime knows which Store it will need to get data from.
What I think I need, is define something like this in my host:
See what I'm getting at? Maybe I'm approaching this all wrong, but I fail to see how I can pass something to host functions from the host itself.
Maybe Runtime::new() could take a Context argument, which the user defines. This context is then passed to every function in the host's context, as the first argument. Not sure how difficult this is, but seems reasonable, as the user will have the context known when instantiating the Runtime. Note that this Context does not need to be available in the Runtime itself, but only by the host. This means that we could pass arguments that are not properly mapped using fp-bindgen, such as my Store in the example above.
note: @Zagitta has already let me know in Discord that they're working on a prototype to do something like this
The text was updated successfully, but these errors were encountered:
I want to give my plugins access to stuff on the host's database. What I'd normally do, is pass my
Store
struct around, which contains methods that you can do to get access to the database. Of course I can't do this with plugins, as theStore
cannot pass the memory boundary. So what I could do, is create aquery
function in my host, and expose that in the plugin runtime. Thatquery
function will still need to access myStore
. In some programming languages, you might use some global context and take theStore
from there, but that's not an option in Rust I think: I need to pass myStore
explicitly to my newquery
function. But how can I do this?However, I have no idea on how I can then pass some context to my runtime, so that my runtime knows which
Store
it will need to get data from.What I think I need, is define something like this in my host:
But my protocol needs to have something like this:
See what I'm getting at? Maybe I'm approaching this all wrong, but I fail to see how I can pass something to host functions from the host itself.
Maybe
Runtime::new()
could take a Context argument, which the user defines. Thiscontext
is then passed to every function in the host's context, as the first argument. Not sure how difficult this is, but seems reasonable, as the user will have the context known when instantiating the Runtime. Note that thisContext
does not need to be available in the Runtime itself, but only by the host. This means that we could pass arguments that are not properly mapped usingfp-bindgen
, such as myStore
in the example above.note: @Zagitta has already let me know in Discord that they're working on a prototype to do something like this
The text was updated successfully, but these errors were encountered: