-
Notifications
You must be signed in to change notification settings - Fork 85
Add pub unsafe accessors for object/session handles and ObjectHandle new #317
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
Add pub unsafe accessors for object/session handles and ObjectHandle new #317
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice! Thank you!
Was wondering if you could add a small test using those if that would make sense?
822af1e
to
7c0839c
Compare
Absolutely! Added a test case that resembles what I'm doing and exercises the new functions. Made small changes to the common test mod. |
Happy to move/reformat anything if it aligns more with convention. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the added test! It will be a very nice example to anyone wanting to do similar things 👍
7c0839c
to
5de9fbf
Compare
If you want to make it easier for now and get the PR merged, you could just add a simple "smoke" test where we try to clone an existing ObjectHandle from its raw handle. Then we can think about how making your more complex and useful example in a separate one? |
Folks, is there a reason getting the raw handle is considered unsafe? As far as I saw in Rust, usually it's the constructor functions that are (As a side-note, quite a lot of structures already have inner accessors via Thanks for your input! |
I thought about the same when reading as well! I also agree that it should be ok to make them safe as getting the value should not be a safety issue per se! |
Great to hear. I think just extending the visibility of Just as a curiosity, Rust docs for
and even though that function is not marked |
I'm very happy to remove the new handle accessors and just change the existing ones to pub. Are there any other feelings for the ObjectHandle |
FWIW I'm okay with what's in here already, just wondering if there are more "low hanging fruit" to be harvested ;) |
Happy to harvest whatever is helpful - there are a number of places where The other places it's used are just outside unsafe blocks so small to change. |
3340e30
to
bfe4634
Compare
Did this for now just to exercise the new
And still happy to make these changes if the two new unsafe blocks are fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for going through the comments! For me it's good as is. We can change all calls from new_from_raw
to new
in a later PR for all handle types.
The CI is failing, maybe #318 should be merged before?
Gotcha, will rebase when available. |
You can try now! |
…new_from_raw Signed-off-by: Jack Shannon <jhshannon17@gmail.com>
bfe4634
to
a99ad88
Compare
pushed! |
Happy to have this finally merged 🥳 Thanks for your work @jhshannon17 ! 🙇 |
Excellent, thank you all! |
As detailed in this issue, in order to allow for vendor extensions to the standard, raw session/object handles need to be accessible outside of the crate. Creating new methods marked
unsafe
was the preferred way to allow this extension.new_from_raw
method to ObjectHandle to allow creationraw_handle
to ObjectHandle to get the underlying handleraw_handle
to Session to get the underlying handle