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

Move winapi support into a new unstable crate #537

Closed
KodrAus opened this issue Oct 30, 2021 · 4 comments · Fixed by #548
Closed

Move winapi support into a new unstable crate #537

KodrAus opened this issue Oct 30, 2021 · 4 comments · Fixed by #548

Comments

@KodrAus
Copy link
Member

KodrAus commented Oct 30, 2021

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.

@kinggoesgaming
Copy link
Member

Are these traits are to be in uuid? I might work on Tuesday

@KodrAus
Copy link
Member Author

KodrAus commented Oct 30, 2021

@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.

@KodrAus
Copy link
Member Author

KodrAus commented Oct 31, 2021

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());
}

@KodrAus
Copy link
Member Author

KodrAus commented Oct 31, 2021

The original PR that added GUID support (#336) was correct, and we regressed in #345.

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

Successfully merging a pull request may close this issue.

2 participants