Struct guid_create::GUID[][src]

pub struct GUID { /* fields omitted */ }

A GUID backed by 16 byte array.

Methods

impl GUID
[src]

Construct a GUID from components.

extern crate guid_create;
let guid = guid_create::GUID::build_from_components(
    0x87935CDE,
    0x7094,
    0x4C2B,
    &[ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]
    );

assert_eq!(guid.data1(), 0x87935CDE);
assert_eq!(guid.data2(), 0x7094);
assert_eq!(guid.data3(), 0x4C2B);
assert_eq!(guid.data4(), [ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]);
assert_eq!(guid.to_string(), "87935CDE-7094-4C2B-A0F4-DD7D512DD261");

Construct a GUID from 16 bytes.

extern crate guid_create;
let guid = guid_create::GUID::build_from_slice(&[
    0x87, 0x93, 0x5C, 0xDE, 0x70, 0x94, 0x4C, 0x2B, 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D,
    0xD2, 0x61,
]);
assert_eq!(guid.data1(), 0x87935CDE);
assert_eq!(guid.data2(), 0x7094);
assert_eq!(guid.data3(), 0x4C2B);
assert_eq!(
    guid.data4(),
    [0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61]
);
assert_eq!(guid.to_string(), "87935CDE-7094-4C2B-A0F4-DD7D512DD261");

Construct a GUID from a string. Leverages guid-parser for the parsing.

extern crate guid_create;
let guid = guid_create::GUID::parse("87935CDE-7094-4C2B-A0F4-DD7D512DD261").unwrap();

assert_eq!(guid.data1(), 0x87935CDE);
assert_eq!(guid.data2(), 0x7094);
assert_eq!(guid.data3(), 0x4C2B);
assert_eq!(guid.data4(), [ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]);
assert_eq!(guid.to_string(), "87935CDE-7094-4C2B-A0F4-DD7D512DD261");

Generates a new GUID with 16 random bytes.

The first four bytes.

extern crate guid_create;
let guid = guid_create::GUID::build_from_components(
    500,
    600,
    700,
    &[ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]
    );

assert_eq!(guid.data1(), 500);

Bytes 5 and 6.

extern crate guid_create;
let guid = guid_create::GUID::build_from_components(
    500,
    600,
    700,
    &[ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]
    );

assert_eq!(guid.data2(), 600);

Bytes 7 and 8.

extern crate guid_create;
let guid = guid_create::GUID::build_from_components(
    500,
    600,
    700,
    &[ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]
    );

assert_eq!(guid.data3(), 700);

The last eight bytes.

extern crate guid_create;
let guid = guid_create::GUID::build_from_components(
    500,
    600,
    700,
    &[ 0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61 ]
    );

assert_eq!(
    guid.data4(),
    [0xA0, 0xF4, 0xDD, 0x7D, 0x51, 0x2D, 0xD2, 0x61]
);

Trait Implementations

impl Copy for GUID
[src]

impl Clone for GUID
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for GUID
[src]

Formats the value using the given formatter. Read more

impl PartialEq for GUID
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for GUID
[src]

impl Display for GUID
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for GUID

impl Sync for GUID