-
Notifications
You must be signed in to change notification settings - Fork 921
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
Use wrapper type for CFUUID #4032
base: master
Are you sure you want to change the base?
Conversation
Saw #4031 randomly and thought I'd take stab at it. I'm not sure this is releasing the right thing but it seems to work without issues. Please someone double check :) |
b662d4e
to
87d8a93
Compare
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.
I think such wrappers actually already exist? Use core_foundation::uuid::CFUUID
and CFUUID::wrap_under_create_rule
?
Also, I was a bit unsure, but read the docs on ARC does seem to suggest that since the function contains |
Oh nice, didn't know about this! Also took me look into the source to confirm it calls release :) It doesn't seem to derive Hash, PartialOrd, and Ord, though… I can try to get this added upstream but I'm not even sure if treating these UUIDs as Ord makes sense? |
|
But I'd also be fine with converting them to a pointer, and implementing |
This no longer exposes `CGDisplayCreateUUIDFromDisplayID` and instead offers a new `CfUuid` type that can be created from a display ID and also cleans itself up on drop. Closes rust-windowing#4031
87d8a93
to
4b5ee2b
Compare
Sorry, had other stuff going on. I've updated it to compare/hash/sort by UUID bytes. It's not the most concise but does the job. |
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 good, only a small nit
@@ -133,15 +134,43 @@ impl VideoModeHandle { | |||
#[derive(Clone)] | |||
pub struct MonitorHandle(CGDirectDisplayID); | |||
|
|||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | |||
struct MonitorUuid([u8; 16]); |
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.
You shouldn't need this, you can just use [u8; 16]
(or if you really want, type MonitorUuid = [u8; 16]
).
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.
I usually go for explicit newtypes, and even had an implementation where this had From<CFUUIDBytes>
but I didn't want to overdo it. I'll swap it for the type alias :)
This no longer exposes
CGDisplayCreateUUIDFromDisplayID
and instead offers a newCfUuid
type that can be created from a display ID and also cleans itself up on drop.Closes #4031
changelog
module if knowledge of this change could be valuable to users