#identifier #parser #guid

guid-parser

Chomp parser for Windows GUID literals

1 unstable release

Uses old Rust 2015

0.1.0 Feb 12, 2018

#20 in #guid

Download history 51/week @ 2024-07-21 57/week @ 2024-07-28 49/week @ 2024-08-04 69/week @ 2024-08-11 40/week @ 2024-08-18 53/week @ 2024-08-25 59/week @ 2024-09-01 102/week @ 2024-09-08 61/week @ 2024-09-15 74/week @ 2024-09-22 69/week @ 2024-09-29 20/week @ 2024-10-06 53/week @ 2024-10-13 44/week @ 2024-10-20 42/week @ 2024-10-27 58/week @ 2024-11-03

198 downloads per month
Used in 6 crates (3 directly)

MIT/Apache

10KB
188 lines

GUID

This crate provides a guid! macro for expressing GUID structs with a convenient literal syntax. A GUID is a Windows globally unique identifier, usually expressed in the following format:

{6B29FC40-CA47-1067-B31D-00DD010662DA}

With this crate, a GUID can be generated with the syntax:

guid!{"6B29FC40-CA47-1067-B31D-00DD010662DA"}

Example

#[macro_use]
extern crate guid;

use guid::GUID;

const MY_GUID: GUID = guid!{"6B29FC40-CA47-1067-B31D-00DD010662DA"};

fn main() {
    assert_eq!(MY_GUID.Data1, 0x6B29FC40);
    assert_eq!(MY_GUID.Data2, 0xCA47);
    assert_eq!(MY_GUID.Data3, 0x1067);
    assert_eq!(MY_GUID.Data4, [ 0xB3, 0x1D, 0x00, 0xDD, 0x01, 0x06, 0x62, 0xDA ]);
}

The GUID type is re-exported from the winapi crate, and is only available in Windows. The guid! macro is also only available in Windows.

This crate also provides a parser, which can be used to parse GUID strings at runtime. The parser is only available to generate an array of bytes on non-Windows platforms. In Windows, this crate defines a parser that produces a GUID struct.

Compatibility

This crate supports all versions of Rust (stable and nightly) starting with Rust 1.15.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

This crate provides a chomp parser for Windows GUIDs, using the most customary syntax used for example by the tool guidgen.exe that comes with Microsoft Visual Studio. For example, the GUID 6B29FC40-CA47-1067-B31D-00DD010662DA would be represented by the string "6B29FC40-CA47-1067-B31D-00DD010662DA".

See the documentation for the chunks function below for an example.

Dependencies

~1MB
~18K SLoC