-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #548 from KodrAus/chore/remove-winapi
Remove winapi support in favor of examples
- Loading branch information
Showing
14 changed files
with
189 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ struct Uuid; | |
|
||
const _: Id = id!("67e55044-10b1-426f-9247-bb680e5fe0c8"); | ||
|
||
fn main() {} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! Generating a random UUID. | ||
//! | ||
//! If you enable the `v4` feature you can generate random UUIDs. | ||
|
||
#[test] | ||
#[cfg(feature = "v4")] | ||
fn generate_random_uuid() { | ||
use uuid::Uuid; | ||
|
||
let uuid = Uuid::new_v4(); | ||
|
||
assert_eq!(Some(uuid::Version::Random), uuid.get_version()); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//! Using the `uuid!` macro. | ||
//! | ||
//! If you enable the `macros` feature you can use the `uuid!` macro. | ||
//! `uuid!` will parse encoded UUIDs at compile time instead of at runtime. | ||
//! If you've got a fixed UUID string handy then consider using `uuid!` instead | ||
//! of `Uuid::parse_str` or `str::parse`. | ||
|
||
#[test] | ||
#[cfg(feature = "macros")] | ||
fn parse_uuid_at_compile_time() { | ||
use uuid::uuid; | ||
|
||
let uuid = uuid!("67e55044-10b1-426f-9247-bb680e5fe0c8"); | ||
|
||
assert_eq!(Some(uuid::Version::Random), uuid.get_version()); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! Converting between Windows GUIDs and UUIDs. | ||
//! | ||
//! Windows GUIDs are specified as using mixed endianness. | ||
//! What you get will depend on the source of the GUID. | ||
//! Functions like `CoCreateGuid` will generate a valid UUID so | ||
//! the fields will be naturally ordered for `Uuid::from_fields`. | ||
//! Other GUIDs might need to be passed to `Uuid::from_fields_le` | ||
//! to have their ordering swapped. | ||
|
||
#[test] | ||
#[cfg(windows)] | ||
fn guid_to_uuid() { | ||
use uuid::Uuid; | ||
use winapi::shared::guiddef; | ||
|
||
let guid_in = guiddef::GUID { | ||
Data1: 0x4a35229d, | ||
Data2: 0x5527, | ||
Data3: 0x4f30, | ||
Data4: [0x86, 0x47, 0x9d, 0xc5, 0x4e, 0x1e, 0xe1, 0xe8], | ||
}; | ||
|
||
let uuid = Uuid::from_fields( | ||
guid_in.Data1, | ||
guid_in.Data2, | ||
guid_in.Data3, | ||
&guid_in.Data4, | ||
); | ||
|
||
let guid_out = { | ||
let fields = uuid.as_fields(); | ||
|
||
guiddef::GUID { | ||
Data1: fields.0, | ||
Data2: fields.1, | ||
Data3: fields.2, | ||
Data4: *fields.3, | ||
} | ||
}; | ||
|
||
assert_eq!( | ||
(guid_in.Data1, guid_in.Data2, guid_in.Data3, guid_in.Data4), | ||
( | ||
guid_out.Data1, | ||
guid_out.Data2, | ||
guid_out.Data3, | ||
guid_out.Data4 | ||
) | ||
); | ||
} | ||
|
||
#[test] | ||
#[cfg(windows)] | ||
fn uuid_from_cocreateguid() { | ||
use uuid::{Uuid, Variant, Version}; | ||
use winapi::{ | ||
shared::guiddef, | ||
um::combaseapi::CoCreateGuid, | ||
}; | ||
|
||
let mut guid = guiddef::GUID::default(); | ||
|
||
unsafe { | ||
CoCreateGuid(&mut guid as *mut _); | ||
} | ||
|
||
let uuid = | ||
Uuid::from_fields(guid.Data1, guid.Data2, guid.Data3, &guid.Data4); | ||
|
||
assert_eq!(Variant::RFC4122, uuid.get_variant()); | ||
assert_eq!(Some(Version::Random), uuid.get_version()); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "uuid-macros" | ||
name = "uuid_macro" | ||
version = "0.0.0" | ||
edition = "2018" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.