toULongs

inline fun <T> toULongs(action: (mostSignificantBits: ULong, leastSignificantBits: ULong) -> T): T(source)

Executes a specified block of code, providing access to the uuid's bits in the form of two ULong values.

This function is intended for use when one needs to perform bitwise operations with the uuid. For example, to identify whether this uuid is of the IETF variant (variant 2):

val isIetfVariant = uuid.toULongs { _, leastSignificantBits ->
(leastSignificantBits shr 62) == 2uL
}

The action will receive two ULong arguments:

  • mostSignificantBits: The most significant 64 bits of this uuid presented in big-endian byte order.

  • leastSignificantBits: The least significant 64 bits of this uuid presented in big-endian byte order.

For example, for the uuid 550e8400-e29b-41d4-a716-446655440000, the breakdown is the following:

  • mostSignificantBits = 0x550e8400e29b41d4uL.

  • leastSignificantBits = 0xa716446655440000uL.

Since Kotlin

2.0

Return

The result of action.

Parameters

action

A function that takes two ULong arguments (mostSignificantBits, leastSignificantBits). This function is guaranteed to be called exactly once.

See also