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 pass multiple references as a context for the query execution.
If I only have one Database struct, then I can make Context = Database and all API is designed in a way that it would accept a reference.
However, what if I have two databases? Context = (Database1, Database2) will not work as I don't have them in one tuple and I cannot move them.
Context = (&Database1, &Database2) doesn't work because of lifetimes, as it seems like there is no way to link lifetime of these references to the lifetime of the request.execute.
I also tried to use trait as a Context (since only a reference is passed around, it should be possible to have support for these), so reference to context becomes trait object (and I can hide stuff in the concrete implementation), but compiler would require that Context is Sized (which I tried to relax by specifying CtxT to be ?Sized everywhere, but it didn't work, don't remember why, though...).
Any advice here?
I also have similar problem with TypeInfo. I have a repository of types and I want to have a reference to it inside each concrete TypeInfo I'm having. As an option, I can build a completely self-sustained TypeInfo's, but I would prefer to have them small and shallow and reference this global type registry for more meta-info for types.
Is there a way to do it better (currently I just use unsafe pointers as a temporary remedy...)?
The text was updated successfully, but these errors were encountered:
I want to pass multiple references as a context for the query execution.
If I only have one
Database
struct, then I can makeContext = Database
and all API is designed in a way that it would accept a reference.However, what if I have two databases?
Context = (Database1, Database2)
will not work as I don't have them in one tuple and I cannot move them.Context = (&Database1, &Database2)
doesn't work because of lifetimes, as it seems like there is no way to link lifetime of these references to the lifetime of therequest.execute
.I also tried to use trait as a Context (since only a reference is passed around, it should be possible to have support for these), so reference to context becomes trait object (and I can hide stuff in the concrete implementation), but compiler would require that
Context
isSized
(which I tried to relax by specifyingCtxT
to be?Sized
everywhere, but it didn't work, don't remember why, though...).Any advice here?
I also have similar problem with
TypeInfo
. I have a repository oftypes
and I want to have a reference to it inside each concrete TypeInfo I'm having. As an option, I can build a completely self-sustained TypeInfo's, but I would prefer to have them small and shallow and reference this global type registry for more meta-info for types.Is there a way to do it better (currently I just use
unsafe
pointers as a temporary remedy...)?The text was updated successfully, but these errors were encountered: