Struct guid_create::GUID[][src]

pub struct GUID { /* fields omitted */ }
Expand description

A GUID backed by 16 byte array.

Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The error type produced by a failed conversion.

Convert the given value into an approximately equivalent representation.

The error type produced by a failed conversion.

Convert the subject into an approximately equivalent representation.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Approximate the subject with the default scheme.

Approximate the subject with a specific scheme.

Approximate the subject to a given type with the default scheme.

Approximate the subject to a given type with a specific scheme.

Convert the subject to a given type.

Attempt to convert the subject to a given type.

Attempt a value conversion of the subject to a given type.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The error type produced by a failed conversion.

Convert the given value into the subject type.

The type returned in the event of a conversion error.

Performs the conversion.

The error type produced by a failed conversion.

Convert the subject into the destination type.

The type returned in the event of a conversion error.

Performs the conversion.

The error type produced by a failed conversion.

Convert the given value into an exactly equivalent representation.

The error type produced by a failed conversion.

Convert the subject into an exactly equivalent representation.