-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query by reference? #35
Comments
Tentative conclusion: return guards, and only support single references. We would like to support returning for complex reference structures, like pairs of references. Aside from returning guards, the main other approach is to pass in a closure that takes the &QueryResult as its argument. In practice, that will be functionally equivalent – both of them make a guard exist within a particular scope, the closure just looks weirder. The closure approach doesn't have the problem with I don't currently have a use case for returning complex structures. Detailed design: we currently have
(That's going to change due to some other API issues, but I'm ignoring that for now.) I propose to add:
And Accessor will have corresponding additional query_ref() function that returns a guard. This allows auditing code to clone the result and test events by feeding them references to the clone. Auditing code would also audit that query() and query_ref() always return equal results. |
A similar approach for more complex structures would look something like this:
Those methods are specifically the ones needed to store copies of the queried value, and feed those copies back into later queries. I believe GeneralizedReference COULD be blanket-implemented for all &T, Option<GeneralizedReference<'a,T>>, (GeneralizedReference<'a,T0>, ...), etc.. It was only trying to implement PossiblyBorrowedStewardData for T itself that caused conflicting impl issues. This would require us manually implementing a more complex guard type for Also, I believe this feature can be grafted on later without breaking existing uses. In the worst case, it could be added as a third query trait/function and definitely not break existing uses. Conclusion: Save labor by not implementing this generalized version of this now, because the features and/or requirements could change by the time we get around to it. However, do implement basic query_ref() because it's simpler and its absence is much more glaring. |
Implemented the basic version. Closing this issue for now, although we might make a new issue for the more generalized version at some point in the future. |
An event might want to look around in a medium-sized DataTimeline, in a way that would be more efficient using references than by first copying all the data it might be going to use.
This is tricky because it involves making the query API much more complex, and probably returning guards rather than plain references.
There might be other approaches that could accomplish the same thing.
The text was updated successfully, but these errors were encountered: