Move winapi support into a new unstable crate
KodrAus opened this issue · comments
For #113
Move the winapi
support into a new unstable crate that's dedicated to UUID conversions:
pub trait IntoUuid {
fn into_uuid(self) -> Uuid;
}
pub trait FromUuid {
fn from_uuid(uuid: Uuid) -> Self;
}
We can then implement this trait for winapi
's Guid
and for the windows-rs
Guid
.
This will move our last remaining unstable public dependency out of the uuid
crate so it can be stabilized.
Are these traits are to be in uuid
? I might work on Tuesday
@kinggoesgaming hey! 👋
Ah these traits are specifically for a new crate, called uuid-convert
or something like that. That way we can remove winapi
from uuid
itself and anybody that wants to convert UUIDs can use this new unstable library.
The goal for doing this is so we don’t end up with winapi
’s unstable API in uuid
’s public one so we can safely stabilize uuid
.
It's probably just as well we're looking to move our GUID support out, because I think the unconditional bitflipping we do is actually invalid. If I call CoCreateGuid
and then pass the results to Uuid::from_guid
I should end up with a V4 (random) UUID. But I don't, unless I don't flip the integers:
let mut guid = guiddef::GUID {
Data1: Default::default(),
Data2: Default::default(),
Data3: Default::default(),
Data4: Default::default(),
};
unsafe {
CoCreateGuid(&mut guid as *mut _);
}
let uuid = Uuid::from_guid(guid);
// This fails on `main`
assert_eq!(Some(Version::Random), uuid.get_version());
}