Skip to content
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

[feature request] Expose the session from a Call and Instance from Session #16

Open
aseyboldt opened this issue Mar 12, 2024 · 1 comment

Comments

@aseyboldt
Copy link

Call internally stores a reference to the Session, and similarly Session store a reference to the Instance.

I think it would be useful to provide a method that exposes those to the user. This would for instance be useful if we have a Call stored inside a struct. This struct can't also contain the session and instance, because of the lifetime requirements. So whenever the function should be called (and results inspected) the session and instance has to be provided externally.

By the way a small design question: I think the references to instance and session inside the Call and Session struct shouldn't strictly speaking be necessary, because the C structures already contain references to those. And since those references use atomic refcounts, the underlying C session and instance will always outlive the Call even without any rust lifetime checks. So is the reference on the rust level really necessary for something, or just to make the logic cleaner?

@gmmyung
Copy link
Owner

gmmyung commented Mar 12, 2024

I think it would be useful to provide a method that exposes those to the user. This would for instance be useful if we have a Call stored inside a struct. This struct can't also contain the session and instance, because of the lifetime requirements. So whenever the function should be called (and results inspected) the session and instance has to be provided externally.

Good point.

By the way a small design question: I think the references to instance and session inside the Call and Session struct shouldn't strictly speaking be necessary, because the C structures already contain references to those. And since those references use atomic refcounts, the underlying C session and instance will always outlive the Call even without any rust lifetime checks. So is the reference on the rust level really necessary for something, or just to make the logic cleaner?

Yes, I should have done it that way, this was just to make the logic cleaner, but this will change as you pointed out.

Feel free tell me if you want to make a PR, or I could work on it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants